no such file to load -- initializer (LoadError) - ruby-on-rails

I have following installed on ubuntu 12
ruby 1.9.2p320
Rails 3.2.6
Now I have old project which is developed into Rails 2 & Ruby 1.8.7
Problem:
When i run below command under old project root directory
ruby ./script/plugin install git://github.com/rails/rails_upgrade.git
Following error comes
Invalid gemspec in [/usr/local/rvm/gems/ruby-1.9.2-p320/specifications/ZenTest-4.9.1.gemspec]: Illformed requirement ["< 2.1, >= 1.8"]
/usr/local/rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require': no such file to load -- initializer (LoadError)
from /usr/local/rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /var/www/project/client/softwallet/config/boot.rb:54:in `load_initializer'
from /var/www/project/client/softwallet/config/boot.rb:38:in `run'
from /var/www/project/client/softwallet/config/boot.rb:11:in `boot!'
from /var/www/project/client/softwallet/config/boot.rb:109:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from ./script/plugin:2:in `<main>'

Upgrading the old rails project to new one and getting the invalid gemspec problem.
Then you have to do the following:
Run gem update --system followed by bundle install.
UPDATE:
You are using the same old config/boot.rb from your older version of rails application.
Do the following:
1) Create a new project directory.
2) Generate a new rails app (Of your new latest rails version)
3) Use boot.rb that is created by it.

This happens when you have incompatible version of the same gem already installed on your environment.
To rectify, either you can uninstall and reinstall the gem or install the gem of the specific version.
Make sure that you do a gem cleanup operation before doing so.

This is how my problem was solved . I was using RVM and if you have edited those .bashrc files then each time while you log in to the shell , do a /bin/bash --login . What this does is , it makes the command line take note of the rvm path you had set and installs them first .
I did this on Ubuntu 12 and it did solve my issue , i don't think doing gem update --system is a good idea as it really kind of messes up the environment forcing one to do an rvm implode and install it all over again .

Related

Cannot launch cloned ruby on rails app - RubyMine

I have cloned an existing project from github. I installed Ruby and installed Rails on my Terminal.
When I do ruby -v I get ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18]
When I do rails -v I get Rails 6.0.3.1
However when I navigate into my project that I want to run on local host and run the same commands:
for ruby -v I get ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18] which is the same.
and for rails -v I get:
Traceback (most recent call last):
4: from bin/rails:3:in `<main>'
3: from bin/rails:3:in `load'
2: from /Users/angelainniss/WebstormProjects/legitkitchen/bin/spring:8:in `<top (required)>'
1: from /Users/angelainniss/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/Users/angelainniss/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- bundler (LoadError)
Has anyone ever had this or do they understand why rails isn't working?
Well, rails command is pretty smart and it knows it will be usually called within the rails project folder. So it have its binstubs - basically those are just a slightly modified commands that lives in your project bin folder, with some additional, project-related power-ups. Regular rails command (and other commands as well) will always check if bin/rails is present in current directory and will use it if it exists. This is why rails -v worked fine outside of your project but didn't inside project folder.
One of the bin/rails superpowers is automatic requiring of all dependencies defined in your project Gemfile. This is normally done through another gem called bundler. Bundler is basically always the first gem you're gona install in your local Ruby environment.
But, you didn't install it yet. Just run gem install bundler to get that running. You will still need to install all the dependencies, you do this via bundle install.
Did you do, gem install bundler before running bundle install after cloning the project?

Rails : Could not locate Gemfile

/Users/mac/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.4/lib/bundler/shared_helpers.rb:24:in `default_gemfile': Could not locate Gemfile (Bundler::GemfileNotFound)
from /Users/mac/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.4/lib/bundler/shared_helpers.rb:29:in `default_lockfile'
from /Users/mac/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.4/lib/bundler.rb:253:in `default_lockfile'
from /Users/mac/bin/spring:10:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
hi,
when i try to run 'rails new myproject' or 'rails -v' i have this message but rails is installed. i don't understand. Someone can help me.
Thanks for your help.
I had the exact problem.
As it turned out, the problem was I had a hidden ./bin directory.
When I run rails new myapp, it's using binaries in the bin folder. In my case it was ./bin/spring specifically.
I removed this ./bin directory and all is well now.
It's either not in the proper path or it isn't installed. Do this gem install bundler also if you are running rails -v you should get a version like this:
rails -v
Rails 4.2.0.beta2
If you don't, then that means rails is not installed either. Run gem install rails
Here is information of setting up rails: http://guides.rubyonrails.org/getting_started.html

Running local server for Rails 2.3 app?

I am trying to run a Rails 2.3 app locally.
script/server gives me these errors:
bash: script/server: Permission denied
bash: parse_git_branch: command not found
script/server gives me the error:
/Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require': cannot load such file -- initializer (LoadError)
from /Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:55:in `load_initializer'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:38:in `run'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:11:in `boot!'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:110:in `<top (required)>'
from /Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from script/server:2:in `<main>'
bash: parse_git_branch: command not found
Any ideas of how I can get this to run locally?
This question is what I've been doing for the past month. I would have loved to use Rails 4, but I know better than to try it!
Install rvm or rbenv, then get into a server that correctly runs this app, and run
ruby --version
gem list > ~/myGems.txt
Using rvm or rbenv, install the exact same version of Ruby.
(Tip: whenever I say "exact same", you can fudge by bumping the revision. For example, given a gem with version 0.1.4, if it has subsequent versions 0.1.5, 0.1.6, and 0.2.0, you can bump to 0.1.6, if that will save you some grief. The revision numbers, 0.1.*, are supposed to be only bug fixes. But a minor version bump, 0.2.0, has higher odds of breaking things. I kept the same version of Ruby, but I bumped rails to 2.3.14.)
Using rvm or rbenv, install the same version of Ruby as currently runs on this app's main server.
Inside this Ruby environment (with both which ruby and ruby --version reporting the correct answers), install each gem in myGems.txt, like this:
gem install --ignore-dependencies --no-rdoc --no-ri my_gem -v=0.1.4
The --ignore-dependencies is critical, because some gems from the Pleistocene Epoch, 2009, don't specify their dependencies' versions. When some dumb 2009 gem pulls in the 2013 rake, you will be utterly screwed, because reverting that rake is really hard. And don't forget to set the -v to the same value as myGems.txt reports!
After all that, try simple rake commands like rake routes. Post any bugs you get as fresh questions, but remember to point out Rails 2.3 in the subject so nobody mis-answers with the modern fixes.
And if this app has tests or specs, getting them running should be a top priority, so you can resume TDD, leaning on the tests to allow you to make sick changes.

Rails cannot load rubygems/defaults file on Windows

Versions, dependencies, and other information:
Ruby: 1.9.3p392 (2013-02-22) [i386-mingw32]
Rails: 3.2.13
Gemfile located at: http://pastebin.com/z9u40Jca
For some reason, whenever I run any gem based command, it gives me this error:
$ rails s
c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/rubygems.rb:30:in `require': cannot l
oad such file -- rubygems/defaults (LoadError)
from c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/rubygems.rb:30:in `<top
(required)>'
from <internal:gem_prelude>:1:in `require'
from <internal:gem_prelude>:1:in `<compiled>'
I have tried deleting ruby 2.0.0 from pik and the rails installer folder, because another SO thread said that would fix it. The commands were working as of 5 hours ago, and must have stopped right when I finished using the rails console (part of learning rails from this tutorial, it was just basic math and string manipulation, so I don't think I screwed something up). Any ideas on what I should do?
Try deleting 'ruby '1.9.3' ' from your gem file. It shouldn't be causing a problem, but I've seen situations where it has.
I don't know if I did something I don't know about, but to the best of my knowledge, adding the gem "bootstrap-sass" at version 2.3.2.0 got it working again. I doubt that it was adding that exact gem that was the solution, but you never know.

Error with new Rails 3.2.8 project - `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)

I've just created a new amazon Linux instance and installed ruby 1.9.3 and rails 3.2.8.
Upon creating a new project I immediately receive failures due to sqlite3. The error is:
[root#xxxxx fun]# rails server
/usr/local/share/gems/gems/sqlite3-1.3.6/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
from /usr/local/share/gems/gems/sqlite3-1.3.6/lib/sqlite3.rb:6:in `rescue in <top (required)>'
from /usr/local/share/gems/gems/sqlite3-1.3.6/lib/sqlite3.rb:2:in `<top (required)>'
I have confirmed that sqlite3 is working just fine outside of rails (i.e. I successfully created a database, did inserts/reads using ruby code). Here is a quick show of loading sqlite3 in irb:
irb(main):001:0> require 'sqlite3'
=> true
I'm all up to date with bundle install. sqlite3 is at version 1.3.6
I have the following packages installed:
ruby19-1.9.3.0-7.17.amzn1.i686
ruby19-devel-1.9.3.0-7.17.amzn1.i686
ruby19-irb-1.9.3.0-7.17.amzn1.noarch
ruby19-libs-1.9.3.0-7.17.amzn1.i686
rubygem19-io-console-0.3-7.17.amzn1.i686
rubygem19-rdoc-3.9.4-7.17.amzn1.i686
rubygems19-1.8.11-7.17.amzn1.noarch
sqlite-3.6.20-1.8.amzn1.i686
sqlite-devel-3.6.20-1.8.amzn1.i686
Any ideas on what I could try to get things working? Thanks!
Update
For "fun" I commented out the gem sqlite3 line from my Gemfile and tried "rails server" again. First it complained about not having a javascript runtime (which I could fix) but then it is getting the following. There seems to be something royally wrong with my install.
[root#xxxx fun]# rails server
/usr/local/share/gems/gems/railties-3.2.8/lib/rails/railtie/configuration.rb:85:in `method_missing': undefined method `active_record' for #<Rails::Application::Configuration:0x9e68f58> (NoMethodError)
from /srv/rails/fun/config/application.rb:54:in `<class:Application>'
from /srv/rails/fun/config/application.rb:13:in `<module:Fun>'
from /srv/rails/fun/config/application.rb:12:in `<top (required)>'
You may have a path problem.
To see if you have more than one version of Ruby, Rails, or gem installed:
find / | grep bin/ruby
    find / | grep bin/rails
    find / | grep bin/gem
On Amazon servers, I typically keep the system Ruby as is, and install my own current Ruby by using the excellent ruby-build script (better than RVM, in my opinon).
https://github.com/sstephenson/ruby-build
If you do have more than one Ruby, I suggest that you set your environment to choose one, for example by using ruby-build or by setting your PATH in your .bashrc file or /etc/environment file something like this:
PATH=/opt/ruby/1.9.1-p134/bin;$PATH
If you're using RVM, I suggest you uninstall it and change to use ruby-build.
To uninstall RVM, I use this script:
https://github.com/SixArm/sixarm_unix_shell_scripts/blob/master/rvm-uninstall-danger

Resources