Rails3: How to manage tainted gem - ruby-on-rails-3

I'm a n00b in Rails and in Rails 3. I had to patch activerecord-jdbc-adapter source locally because of a bug. See Rails 3 ActiveRecord chaining for details. I modified locally lib/arel/visitors/sql_server.rb as described by the page https://github.com/ystael/activerecord-jdbc-adapter/commit/8815d2fe133afb6774ebe12cc27c3a977dbf7ad2.
I would like to manage these changes until the problem is solved centrally with a special attention on smooth deployment. What commands should I run? Which path should I apply the patch on? Which things should I add to my SVN repo? How will I deploy then?
Here is my Gemfile, maybe counts:
source 'http://rubygems.org'
gem 'rails', '3.0.7'
gem 'will_paginate', '3.0.pre'
gem 'activerecord-jdbcmysql-adapter'
gem 'activerecord-jdbcmssql-adapter'

You can add git repository to you gem command.
gem 'activerecord-jdbcmysql-adapter', :git => 'git://github.com/..REPOSITORY...git'

Related

Bundler::GemRequireError when adding gem

When I make a new Rails project, add gem 'reactive-record', and run rails server, I get a Bundler error: There was an error while trying to load the gem 'reactive-record'. (Bundler::GemRequireError).
What gives? I have Rails 4.2.5 and Ruby 2.1.2.
Cheers!
The latest version of the generator should work very well with the help of Mitch. We collaborated together to make a generator in order to simplify greatly the installation of react.rb and reactive-record.
You should be able to get up and running by adding to your gem file :
gem 'reactive_rails_generator'
Then do a bundle install
and finally :
rails g reactrb:install --all
bundle update
Will install you reactrb, reactive-record and reactive-router.
Once installed, you can create components by doing :
rails g reactrb:component Home::Show
I worked around the problem like this:
Set rvm to use Ruby 2.2.2 and Rails 4.2.4.
Download https://codeload.github.com/catprintlabs/reactive-record/zip/master
Edited reactive-record-master/Gemfile to read:
gem 'reactive-ruby'
gem 'opal'
gem 'opal-browser'
gem 'react-rails'
cd reactive-record-master/spec/test_app
bundle install
rails server
This seemed to work.
Then, I made a new Rails 4.2.4 project. Adding only gem 'reactive-record' to the Gemfile resulted in the same error. Then I made the Gemfile read:
gem 'reactive-ruby'
gem 'opal'
gem 'opal-browser'
gem 'react-rails'
gem 'reactive-record'
And voila, rails server works!
Hope this helps someone else.

Could not find gem 'sprockets (= 2.2.2.backport2) ruby' in the gems available on this machine

I have a problem with my gemset.
I created a new one after a fresh install on my computer, just one step after cloning the repo.
Running bundle install but I get this error
Could not find gem 'sprockets (= 2.2.2.backport2) ruby' in the gems available on this machine
I'm using Rails 3.2.11 and ruby 2.1
I have followed the suggestion of the bootstrap-sass Readme
But it doesn't work
Here is the part of my Gemfile with assets group
group :assets do
gem 'sass-rails', " ~> 3.2.3"
gem 'compass-rails'
gem 'sprockets-rails', '=2.0.0.backport1'
gem 'sprockets', '=2.2.2.backport2'
gem 'bootstrap-sass', '~> 3.1.1'
gem 'coffee-rails', "~> 3.2.1"
gem 'uglifier', '>=1.0.3'
gem 'eco'
gem 'i18n-js'
end
The project works on other machines. What can I do?
UPDATING THE QUESTION
Now I have the same problem but with rbenv, and I don't know how to solve it because rbenv doesn't have gemsets!
I had the same issue yesterday. A colleague of mine came across a Twitter conversation which points to a new fork of Sprockets with a 2.2.2.backport2-type tag.
You can get it on GitHub or add it to your Gemfile:
gem 'sprockets', github: 'tessi/sprockets', branch: '2_2_2_backport2'
I have solved the problem following these steps:
Change the gemfile replacing the sass-rails gem with this one: gem 'sass-rails', github: 'guilleiguaran/sass-rails', branch: 'backport'
Create and use a new empty Gemset
Go here and download this gem sprockets 2.2.2 backport2
Copy the downloaded gem in vendor/cache section
run bundle install
This should solve the problem related to this gem sprockets (= 2.2.2.backport2) ruby because it will be installed by the downloaded one.
Not the best, but I found the gem and cached it (put it in vendor/cache) based on this: https://github.com/aliw77/sprockets-2.2.2.backport2. I have a feeling there's another solution, still looking for it.

Issue when pushing to Heroku. Run `bundle install` elsewhere and add the updated Gemfile.lock to version control

I've been trying to trouble shoot this error now for a couple hours without making any progress. I've tried running bundle install in different environments with no luck. I'm not sure what is happening and I feel as if the error is no longer providing relevant feedback. However, I am using Ruby 1.9.3 and when I push it states that Heroku is using ruby 2.0.0. Could this have something to do with it?
Castillos-MacBook-Pro:reservester-nysum13 castillo$ git push heroku master
Identity added: /Users/castillo/.ssh/id_rsa (/Users/castillo/.ssh/id_rsa)
Counting objects: 66, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (51/51), done.
Writing objects: 100% (66/66), 26.25 KiB, done.
Total 66 (delta 4), reused 38 (delta 1)
-----> Ruby/Rails app detected
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using Bundler version 1.3.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.
You have added to the Gemfile:
* debugger
Bundler Output: You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.
You have added to the Gemfile:
* debugger
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby/Rails app
To git#heroku.com:guarded-sierra-5306.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:guarded-sierra-5306.git'
gem 'debugger' originally was placed outside of the environment group. I moved it to the development group and reran bundle.
Here is my Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'therubyracer'
gem 'twitter-bootstrap-rails'
gem 'carrierwave'
gem 'rmagick'
gem "fog", "~> 1.3.1"
gem "devise"
gem "figaro"
gem "galetahub-simple_captcha", :require => "simple_captcha"
group :development do
gem 'annotate'
gem 'sqlite3'
gem 'rspec-rails', '~> 2.0'
gem 'debugger'
end
group :production do
gem 'pg'
end
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
I got similar error. I tried delete Gemfile.lock file manually, rebundle, push it to git and still no luck.
But finally I make it work by change my rvm version to ruby 2.0.0, precomplie the asset with this command
RAILS_ENV=production bundle exec rake assets:precompile
and delete the Gemfile.lock, rebundle, and push it to github. Last part when you push in to heroku use your branch instead your master, this happen because you not deploying the master branch to heroku master branch with this command:
git push heroku your-branch:master
I had a similar situation. Heroku does not support every ruby version. You may be using an unsupported version.
Check for Heroku Ruby supported versions
Change your local ruby version. For example, if you are using rbenv
rbenv local 2.1.6
bundle install
Push the changes to herokugit push heroku master
You can't expect Heroku to know what version of Ruby you're running locally :-) If you want Heroku to use a particular version, tell it. Add ruby '1.9.3' to your Gemfile for example.
It also looks like you didn't rerun bundle install after putting the gem in development group? Try that.
Then add all the changes to git, commit, and push.
This problem is bacause you commit bad (old) Gemfile.lock to heroku server.
You need to update Gemfile.lock on heroku after adding/removing gems.
Do following steps:
save HEROKU_APP_NAME of existing heroku app ( HEROKU_APP_NAME.herokuapp.com )
remove heroku application from https://dashboard.heroku.com/apps and create new one
rename new heroku app to old HEROKU_APP_NAME
remove Gemfile.lock from your git repo
remove Gemfile.lock form your local project and form .gitignore (if it exist there)
run bundle install
commit changes to git repo ( new created Gemfile.lock )
run git push heroku master

How does bundler know which version of a gem to install?

I have been using the less-rails-bootstrap gem from https://github.com/metaskills/less-rails-bootstrap in my rails 3.1 project.
I want to upgrade to the 2.0wip version of bootstrap and I found a fork with the same name under https://github.com/sgruhier/less-rails-bootstrap
Both version say to install you add gem 'less-rails-bootstrap' to your gemfile.
Well, how is bundler going to know which one to use? What if 20 people had gems with the exact same name?
I guess the bigger question is how to I specify which gem to use?
Bundler will use the one found on http://rubygems.org, which is the one at the first link you posted.
When trying to use an unreleased branch/fork, you should pass the :git option in your Gemfile to tell Bundler to use that git repository:
gem 'less-rails-bootstrap', :git => "git://github.com/sgruhier/less-rails-bootstrap.git"

ruby_threadptr_data_type error

I'm starting up a new rails app with the latest version of rails (3.1.3). Rails crashes when I try to start up the server. First I fixed this bug, and now I'm getting this one
ruby-debug-base19-0.11.25/lib/ruby_debug.so: undefined symbol: ruby_threadptr_data_type
There's a discussion about this going on here, but I can't make enough sense of it to get things to work.
UPDATE
I updated the version of ruby-debug
gem 'ruby-debug-base19x', '~> 0.11.30.pre4'
and have now moved on to this error
linecache19-0.5.12/lib/trace_nums19.so: undefined symbol: ruby_current_thread
Ok, it turns out that both ruby-debug and linecache needed to be manually updated to the latest versions. These lines in my gemfile did the trick
gem 'linecache19', :git => 'git://github.com/mark-moseley/linecache'
gem 'ruby-debug-base19x', '~> 0.11.30.pre4'
gem 'ruby-debug19'
To run specs, you need to run bundle exec rspec -d spec
At last I found the problem. The debugger in RubyMine starts without bundle exec, so it doesn't use linecache19 from git. You need to install it manually.
Resolution of the problem found here: http://youtrack.jetbrains.com/issue/RUBY-9418?projectKey=RUBY
gem uninstall linecache19
gem uninstall ruby-debug-base19x
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
gem install linecache19-0.5.13.gem
gem install ruby-debug-base19x –-pre
Make sure to uninstall all linecache19 and ruby-debug-base19x!
The following lines worked for me:
gem 'linecache19'
gem 'ruby-debug-base19x'
gem 'ruby-debug19', :require => 'ruby-debug'
(Hat tip to declan. His comment didn't work for me, but it gave me the idea to add linecache19.)
after trying all advise on stackoverflow, the following combination worked for me
gem 'linecache19', :git => 'git://github.com/mark-moseley/linecache'
gem 'ruby-debug-base19x', '~> 0.11.30.pre4'
gem 'ruby-debug19'
I'm running Rails 3.1.3 on Ruby 1.9.3-p0 with RVM
when I set :require => 'ruby-debug' the server would not start.
It's repost from this
I also ran into this, and found the solution in Ruby 1.9.3 and ruby-debug. You need to install not-yet-officially-released versions of ruby-debug-base19 and linecache19. The currently released versions indeed cause the exception you had.
Use this gist.
#To install ruby-debug on Ubuntu ruby-1.9.3 you need to download from http://rubyforge.org/frs/?group_id=8883
linecache19-0.5.13.gem
ruby_core_source-0.1.5.gem
ruby-debug19-0.11.6.gem
ruby-debug-base19-0.11.26.gem
#Then in your console
export RVM_SRC=/your/path/to/ruby-1.9.3
# Note, your source path should be something like /home/user/.rvm/src/ruby-1.9.3-p0
gem install archive-tar-minitar
gem install ruby_core_source-0.1.5.gem -- --with-ruby-include=/$RVM_SRC
gem install linecache19-0.5.13.gem -- --with-ruby-include=/$RVM_SRC
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=/$RVM_SRC
gem install ruby-debug19-0.11.6.gem -- --with-ruby-include=/$RVM_SRC
I tried it and it's work!
This is solve of our problems.