I'm applying a patch to my fork of 2.3.15 rails for a workaround for one of the latest security issues.
Previously in my gem file I had -
gem 'rails', '2.3.15'
And everything worked as expected. But for my fork I have
gem 'rails', '2.3.15', :git => 'git#github.com:myrepo/rails.git', :branch => 'CVE-2013-0155-fix'
After doing a bundle install and then running my app with bundle exec ruby script/server as per usual, I'm getting this error -
| ./script/../config/boot.rb:64:in `require': no such file to load -- initializer (LoadError)
I thought that maybe I had just messed something up with my fork but when I point my gemfile to the rails git repo I get the same issue.
gem 'rails', '2.3.15', :git => 'git#github.com:rails/rails.git', :tag => 'v2.3.15'
Can anyone explain to me what's up?
Found an excellent blogpost on the issue here - http://robanderson123.wordpress.com/2013/01/05/applying-backported-security-patches-to-rails-2-3/
The big problem being that rails/2-3-stable doesn't have any gemspecs in the repo. Long story short, did a bundle install with rails set to 2.3.15. Copied the rails gemspecs for activerecord etc out of the specifications directory bundle show rails gives into each of the corresponding directories in my fork of rails. With the exception of the rails gemspec which I copied into the railties directory.
After this gem 'rails', '2.3.15', :git => 'git#github.com:myrepo/rails.git', :branch => 'my-2-3-branch' works as expected.
Related
My Rails 4.2 app fails to load some GitHub hosted gem (installed via bundler v1.8.2). I am using rvm 1.26.10 (master)
In my Gemfile,
gem 'simple_form', '~> 3.1.0'
gem 'actionform', :github => 'rails/actionform'
Bundler install them in different location:
$ bundle show simple_form
/Users/me/.rvm/gems/ruby-2.1.5#my_app/gems/simple_form-3.1.0
$ bundle show actionform
/Users/me/.rvm/gems/ruby-2.1.5#my_app/bundler/gems/actionform-4a858fecf4c2
Rails never load the actionform gem.
After inserting the line //= require action_form to my app/assets/javascript/application.js file, this error comes
Sprockets::FileNotFound at / couldn't find file 'action_form'
However, the action_form.js file exists in the gem file.
Moreover, when i try to reproduce the readme example, i got this error
NameError at /conferences/new uninitialized constant ActionForm
require 'bundler/setup' is in boot.rb
Any advise about this issue?
Thanks!
The problem is a mismatch between the gem name and the file inside the gem. Because the gem is named 'actionform', Bundler will try to require 'actionform', however the file is actually called action_form.
You can tell Bundler the right file name with this syntax:
gem 'actionform', :github => 'rails/actionform', :require => 'action_form'
Note that it is normal for gems from git sources to be installed into a different location than gems installed from gem servers. It has nothing to do with this problem.
In my Rail 3.2.13 gemfile I have added the country_select gem
gem 'country_select', :git => 'git://github.com/stefanpenner/country_select.git'
Rrunning bundle install however loads the wrong version of the gem. It instead loads the out-dated repository at https://github.com/rails/country_select
This happens in my development environment as well as when deploying my app to Heroku.
I was able to overcome this in my dev environment by using the ruby gem specific_install however that doesn't help with heroku.
Any ideas?
You have to update your Gemfile.lock with the git path:
bundle update country_select
It should do the trick.
You can set the branch you want to use on the remote git repository using:
gem 'country_select', :git => 'git://github.com/stefanpenner/country_select.git', branch: 'master'
or event a commit tag:
gem 'country_select', :git => 'git://github.com/stefanpenner/country_select.git', revision: 'commit_tag_here'
Beside, when running in Production, a good practice is to fix your gem versions in order to avoid unwanted gem updates.
I am trying to build the docrails in my system. When I clone the repo and do bundle install as the guides say.
I get the following error
You passed :github as an option for gem 'rails/active_record_deprecated_finders'
, but it is invalid.
Entry in gemfile looks like this:
gem 'rails/active_record_deprecated_finders', github: 'rails/active_record_deprecated_finders'
To avoid that what I am doing is commenting the rest of the line like this:
gem 'rails/active_record_deprecated_finders'#, github: 'rails/active_record_deprecated_finders'
Then it foregoes that and the next problem arrives with the error message saying:
Could not find gem 'active_record_deprecated_finders (>= 0) x86-mingw32' in any
of the gem sources listed in your Gemfile.
Environment specs:
Bundler version 1.0.21
Rails 3.2.3
Win7 64bit
Question
I dont know why its looking for x86 when my System is 64bit.Is there any work around for this? or its a bug?
If gem file couldn't accept github: as parameter why is it there in the first place?
Please let me know if there are any workarounds to this problem
The :github option is just shorthand for a longer :git option:
gem :foo, :github => 'rails/foo'
Is just short for
gem :foo, :git => 'git://github.com/rails/foo.git'
This is new in bundler 1.1 which is why it doesn't work on your setup. You could rewrite the gemfile but it would probably be easier to update bundler. In addition bundler 1.1 is a lot faster than 1.0
I have a git submodule of git://github.com/rails/rails in vendor/rails of my Rails 3 app. This is where an unpacked/vendorized Rails would go prior to 3.0.
How do I instruct my Gemfile that vendor/rails is the correct location, and not my system-wide rails install?
So, some people have noted that you can do simply:
gem 'rails', :path => "vendor/rails"
You can also include a version number, e.g.,
gem 'rails', '3.0.3', :path => "vendor/rails"
Both of these depend on what you actually have in vendor/rails. For example, if I do git checkout v3.0.3 in vendor/rails, both of these will work fine on their own (3.0.3 is the current).
But if I use a beta instead, I seem to need to add some additional dependencies:
gem 'rails', :path => "vendor/rails"
gem 'arel', :git => 'git://github.com/rails/arel.git'
gem 'rack', :git => 'git://github.com/rack/rack.git'
I could also extract these into vendor as git submodules, I suppose, and again use :path.
Do be aware that rack comes from rack/rack on github, not rails/rack. The latter is a fork and hasn't been updated since 2009. I made this mistake and spent hours fixing it.
If you've got older versions of rails installed on your machine, you may also need to take care to use script/rails instead of the rails command.
Isn't it just gem 'rails', '3.0.3', :path => "vendor/rails" in your Gemfile?
Use this line in your Gemfile:
gem 'rails', :path => "vendor/rails"
When I try to include an external gem in my Gemfile (e.g. from github), my RVM doesn't recognize the external gem. It keeps telling me to run "bundle install" even after already doing.
For example, when I log into shell and do a "bundle check", I see that all "dependencies are satisfied" but in my browser, Passenger tells me that my gem is not checked out and to "Please run bundle install".
Just to make it clearer, doing this gives me the issues above:
gem 'thinking-sphinx',
:git => 'git://github.com/freelancing-god/thinking-sphinx.git',
:branch => 'rails3',
:require => 'thinking_sphinx'
But doing this using local gems do work:
gem 'thinking-sphinx'
The backtrace is here. Do you know what the problem could be?
Try:
gem 'thinking-sphinx', '2.0.0.rc2', :require => 'thinking_sphinx'
It's always best to require a specific gem version, rather than just checking out master or a branch still in development.
Your application is probably not running as the intended user.