I was doing development on a ruby on a rails application (v2.3) yesterday and decided to update my iMac to OSX Mavericks. Now, every time I try to run my application locally, I get the following error. Does anyone know whats causing this?
Run like this:
script/server -e development
Error:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- script/../config/boot (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from script/server:2:in `<main>'
script/server (file)
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
It was working fine before installing OSX Mavericks.
Things I Noticed:
the version of ruby installed in now 2.0 (it was v1.8.7 before)
FYI: I'm still fairly new to rails.
After Installing RVM:
Ok so I setup RVM and made sure the version of ruby (1.8.7) and rails (2.3.11) are installed and configured as the default.
Installed RVM:
curl -L https://get.rvm.io | bash -s stable --rails
Install Ruby 1.8.7:
rvm install ruby-1.8.7-p374
Set v1.8.7 as the default version:
rvm --default use 1.8.7
Install Rails v2.3.11:
gem install rails -v 2.3.11
Install all the gems from system
rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system
Now when I run my app, I get the following error: (what am I missing?)
=> Booting WEBrick...
/Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `gem_original_require': no such file to load -- haml (MissingSourceFile)
from /Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `require'
from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:355:in `new_constants_in'
from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/plugins/haml/init.rb:5:in `evaluate_init_rb'
from ./script/../config/../vendor/rails/railties/lib/rails/plugin.rb:95:in `evaluate_init_rb'
from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
from ./script/../config/../vendor/rails/railties/lib/rails/plugin.rb:91:in `evaluate_init_rb'
from ./script/../config/../vendor/rails/railties/lib/rails/plugin.rb:44:in `load'
from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:33:in `load_plugins'
from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:32:in `each'
from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:32:in `load_plugins'
from ./script/../config/../vendor/rails/railties/lib/initializer.rb:292:in `load_plugins'
from ./script/../config/../vendor/rails/railties/lib/initializer.rb:142:in `process'
from ./script/../config/../vendor/rails/railties/lib/initializer.rb:97:in `send'
from ./script/../config/../vendor/rails/railties/lib/initializer.rb:97:in `run'
from /Users/imaginationplus/gitlocal/dfc_workshop/config/environment.rb:14
from /Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `gem_original_require'
from /Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `require'
from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:355:in `new_constants_in'
from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/railties/lib/commands/servers/webrick.rb:59
from /Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `gem_original_require'
from /Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `require'
from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:355:in `new_constants_in'
from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/railties/lib/commands/server.rb:39
from script/server:3:in `require'
from script/server:3
The main thing to understand from this issue is that you cannot rely on the OS for your ruby version or the gems that you are using within a ruby project. As you create additional ruby apps you may run into trouble with this again.
- To manage the gems use Bundler
Bundler maintains a consistent environment for each ruby applications.
- To manage the Ruby versions use rbenv or rvm
the version of ruby installed in now 2.0 (it was v1.8.7 before)
In 2.x version of Ruby, the current directory is no longer in $LOAD_PATH by default. That means that using require to load files relative to the current directory (such as script/../config/boot which expands to simply config/boot) won't work.
Alternatives are:
edit $LOAD_PATH to include the current directory by e.g. $LOAD_PATH << "."
use require_relative
Above solution was found here
Related
Ruby 2.1.3p242 <2014-09-19 revision 47630> [x64-mingw32]
Rails 4.2.0.beta2
I'm running windows 8 on a 64 bit system. I have been using c9 (cloud hosted ubuntu) but want to start using RubyMine IDE on my pc to make everything faster but it's posing some problems.
I've tried pretty much every recommended way including this one:
How do I install sqlite3 for Ruby on Windows?
but I'm still getting the same error message. You help is much appreciated! Please let me know if you have any questions for me.
Full Error message when I run $rails s:
C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `block in require'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:233:in `load_dependency'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta2/lib/active_support/dependencies.rb:248:in `require'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9-x64-mingw32/lib/sqlite3.rb:6:in `rescue in <top (required)>'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9-x64-mingw32/lib/sqlite3.rb:2:in `<top (required)>'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:76:in `require'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:72:in `each'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:72:in `block in require'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:61:in `each'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:61:in `require'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/bundler-1.7.4/lib/bundler.rb:133:in `require'
from C:/Sites/aynulhabib-habib-framework-aca42deddccd/config/application.rb:7:in `<top (required)>'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:78:in `require'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:78:in `block in server'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:75:in `tap'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:75:in `server'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta2/lib/rails/commands.rb:17:in `<top (required)>'
from C:/Sites/aynulhabib-habib-framework-aca42deddccd/bin/rails:8:in `require'
from C:/Sites/aynulhabib-habib-framework-aca42deddccd/bin/rails:8:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
Process finished with exit code 1
fortunately, you don't have to switch to ruby 2.0
there is a solution to this issue, after endless trying...
https://github.com/hwding/sqlite3-ruby-win
Steps
Pre
gem uninstall sqlite3 --all
Source
Download the latest sqlite3-ruby, https://github.com/sparklemotion/sqlite3-ruby
unzip the package
Build
run command-line in the extracted dir
make sure you have your C compiler installed and added to PATH
gem install bundler
bundle install
rake native gem
you'll find a dir named 'pkg' generated
Install
enter dir 'pkg'
gem install --local sqlite3-xxx.gem ('xxx' is version code)
Check
irb
require 'sqlite3'
The issue is that binary sqlite3 gem do not include pre-compiled versions for Ruby 2.1.3
This is mentioned in the sqlite3-ruby mailing list here.
In the folder of your project open terminal and execute:
bundle update sqlite3
bundle update nokogiri
I hope i have helped you ;)
EDIT:
i always recommend using linux/mac for ruby, because some gems may get problematic, because of compiling errors with c
always use bundle to manage your gems, it is much easier*,
you can install it by:
gem install bundler
bundle install - will install all the gems in your Gemfile
the last bundler version is not compatible withe ruby bellow 2.3, so use gem install bundler -v 1.16.4
If you have extracted "exe"s and "dll"s from Sqlite download link to Ruby's bin folder and still have this problem. Try this:
bundle update
gem uninstall sqlite3
Given a choice between multiple versions of sqlite3, choose last option 'All versions'. Enter last number here
Select gem to uninstall:
1. sqlite3-1.3.13
2. sqlite3-1.3.13-x64-mingw32
3. All versions
>3
.
.
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN]
>
y
gem install sqlite3 --platform=ruby
rails s
This should work.
Read through this link for more explanation if above works for you.
I am trying to run rails console. I have tried everything suggested on SO. I have libreadline-6 installed. My ruby version is 2.1.1 and irb is 0.9.6.
/home/xamroc/.rbenv/versions/2.1.1/lib/ruby/2.1.0/irb/completion.rb:9:in `require': cannot load such file -- readline (LoadError)
from /home/xamroc/.rbenv/versions/2.1.1/lib/ruby/2.1.0/irb/completion.rb:9:in `<top (required)>'
from /home/xamroc/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.3/lib/rails/commands/console.rb:3:in `require'
from /home/xamroc/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.3/lib/rails/commands/console.rb:3:in `<top (required)>'
from /home/xamroc/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.3/lib/rails/commands.rb:51:in `require'
from /home/xamroc/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.3/lib/rails/commands.rb:51:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Any suggestions?
Also, I am using rbenv to manage my ruby versions.
You need to install libreadline and also the -dev package and then you need to recompile ruby. When your using rvm you should always run
rvm requirements
first and then download and compile ruby. If your using rvm then you can run
rvm reinstall <version>
to do this.
// Also see: http://vvv.tobiassjosten.net/ruby/readline-in-ruby-with-rbenv/
I'm installing gitorious on my webserver. Everything works fine except git-deamon, I get the following error when I run it
/etc/init.d/git-daemon start
Starting git-daemon: /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:31:in `setup':
You have already activated daemons 1.1.4, but your Gemfile requires daemons 1.1.0.
Consider using bundle exec. (Gem::LoadError)
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:17:in `setup'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler.rb:107:in `setup'
from /var/www/gitorious/script/../config/../config/preinitializer.rb:16
from /var/www/gitorious/script/../config/boot.rb:28:in `load'
from /var/www/gitorious/script/../config/boot.rb:28:in `preinitialize'
from /var/www/gitorious/script/../config/boot.rb:10:in `boot!'
from /var/www/gitorious/script/../config/boot.rb:123
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
from /var/www/gitorious/script/../config/environment.rb:11
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
from /var/www/gitorious/script/git-daemon:11
failure
I have installed enterprise ruby 1.8.7 and ruby gems 1.4.2. I'm running ubuntu 11.04.
How could i solve it?
Thanks
The easy way (but not very future-proof):
gem uninstall daemons
cd /var/www/gitorious
bundle install
The hard way: modify /etc/init.d/git-daemon so that it runs cd /var/www/gitorious && bundle exec /var/www/gitorious/script/git-daemon start
I have upgaded ruby to 1.9.2, rubygems 1.5.0 and installed the latest rails 3.0.3 by following this tutorial:
http://hivelogic.com/articles/ruby-rails-mongrel-mysql-osx
But now my existing project no longer works. If I do a "ruby script/about", I get this:
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- /Users/sneigaard/work/rails/myproject/config/../vendor/rails/railties/lib/initializer (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from /Users/sneigaard/work/rails/myproject/config/boot.rb:45:in `load_initializer'
from /Users/sneigaard/work/rails/myproject/config/boot.rb:38:in `run'
from /Users/sneigaard/work/rails/myproject/config/boot.rb:11:in `boot!'
from /Users/sneigaard/work/rails/myproject/config/boot.rb:110:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from script/about:2:in `<main>'
If I run "mongrel_rails start" I get this error:
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:29:in `gem_original_require': no such file to load -- /Users/sneigaard/work/rails/myproject/config/../vendor/rails/railties/lib/initializer (LoadError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:29:in `require'
from /Users/sneigaard/work/rails/myproject/config/boot.rb:45:in `load_initializer'
from /Users/sneigaard/work/rails/myproject/config/boot.rb:38:in `run'
from /Users/sneigaard/work/rails/myproject/config/boot.rb:11:in `boot!'
from /Users/sneigaard/work/rails/myproject/config/boot.rb:110
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:29:in `require'
from /Users/sneigaard/work/rails/myproject/config/environment.rb:7
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:29:in `require'
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:147:in `rails'
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:113:in `cloaker_'
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `call'
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `listener'
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:99:in `cloaker_'
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `call'
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `initialize'
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `new'
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `run'
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run'
from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
from /usr/bin/mongrel_rails:19:in `load'
from /usr/bin/mongrel_rails:19
In script/server I have this:
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server'
I have searched and searched the net, but I can not figure this out, and my project is stuck :( Please help me.
Thank you
Søren
it's rails server does that spit out the same error? you appear to be using rails 2 commands in rails 3. also, are all your gems loaded into 1.9.2? you have to reload everything when switching rubies.
some misconfiguration with your ruby , if you type
which ruby
gem environment
and
ruby -v
it's all coerent?
I will suggest to use RVM
very very simple to setup good documentation and usefull for your buisness.
also seems that your project is still in rails 2.3.* not 3.0.* , in rails 3 thear is not a script/server script file.
install rvm ruby 1.9.2 and the right gem to your project.
hope this could help.
I had this problem when upgrading an app from 1.8.7 to 1.9.2.
In Ruby 1.9.2, Kernel.require doesn't work like 1.8, instead it seems they want you to use
Kernel.require_relative
See here for solutions that will work in both rubies
Ruby: require vs require_relative - best practice to workaround running in both Ruby <1.9.2 and >=1.9.2
I'm trying to start the console (irb) in Ruby 1.9 with Rails 2.3.4. I have two versions installed of Ruby (1.9 & 1.8.6) and I run the Ruby 1.9 by calling: rake19, ruby19, gem19...etc
And they work fine in all situations except this! it seems that its trying to load Ruby 1.8 instead! Do you know how I can change that?
Macintosh-10:favquote tammam56$ ruby19 script/console
Loading development environment (Rails 2.3.4)
/Users/tammam56/rubydev/favquote/config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:1:in `require': no such file to load -- rubygems (LoadError)
from /Users/tammam56/rubydev/favquote/config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:1
from /Users/tammam56/rubydev/favquote/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:1:in `require'
from /Users/tammam56/rubydev/favquote/config/../vendor/rails/railties/lib/rails/gem_dependency.rb:1
from /Users/tammam56/rubydev/favquote/config/../vendor/rails/railties/lib/initializer.rb:10:in `require'
from /Users/tammam56/rubydev/favquote/config/../vendor/rails/railties/lib/initializer.rb:10
from /Users/tammam56/rubydev/favquote/config/boot.rb:45:in `require'
from /Users/tammam56/rubydev/favquote/config/boot.rb:45:in `load_initializer'
from /Users/tammam56/rubydev/favquote/config/boot.rb:38:in `run'
from /Users/tammam56/rubydev/favquote/config/boot.rb:11:in `boot!'
from /Users/tammam56/rubydev/favquote/config/boot.rb:110
from /Users/tammam56/rubydev/favquote/config/environment.rb:8:in `require'
from /Users/tammam56/rubydev/favquote/config/environment.rb:8
from /opt/local/lib/ruby/1.8/irb/init.rb:252:in `require'
from /opt/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules'
from /opt/local/lib/ruby/1.8/irb/init.rb:250:in `each'
from /opt/local/lib/ruby/1.8/irb/init.rb:250:in `load_modules'
from /opt/local/lib/ruby/1.8/irb/init.rb:21:in `setup'
from /opt/local/lib/ruby/1.8/irb.rb:54:in `start'
from /opt/local/bin/irb:13
Thanks,
Tam
This is happening because script/console is calling irb (1.8). Assuming you have irb19 for ruby 1.9 you could do:
script/console --irb='irb19'
However there may still be problems with rails gems. If so, I'd recommend using rvm to manage your different rubys. When using rvm you will need to install gems separately for ruby 1.9 and 1.8.