I seem to have correct include path, but a lot of gems can’t be loaded
via “required”. What could be the problem?
test.rb
#!/usr/bin/ruby -w
require “cgi” # can load this
require “actionpack” # can not load this
/var/www/ruby/test.rb
/var/www/ruby/test.rb:3:in require': no such file to load -- /var/lib/gems/1.9.2/gems/passenger-3.0.11/test/stub/vendor_rails/minimal/actionpack (LoadError) from /var/www/ruby/test.rb:3:in
’
rails server
/root/src/config/boot.rb:6:in require': no such file to load -- bundler/setup (LoadError) from /root/src/config/boot.rb:6:in
<top (required)>’
from script/rails:5:in require' from script/rails:5:in
’
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.2 (2010-07-02 patchlevel -1) [i486-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.2/gems/
- RUBY EXECUTABLE: /usr/bin/ruby1.9.2
- EXECUTABLE DIRECTORY: /var/lib/gems/1.9.2/gems/bin
- RUBYGEMS PLATFORMS:
- GEM PATHS:
- /var/lib/gems/1.9.2/gems/
- /root/.gem/ruby/1.9.2
- /var/lib/gems/1.9.2
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
ls -l /var/lib/gems/1.9.2/gems/
total 296
drwxr-xr-x 4 root root 4096 2011-05-10 12:05 abstract-1.0.0
drwxr-xr-x 3 root root 4096 2011-05-10 12:05 actionmailer-3.0.6
drwxr-xr-x 3 root root 4096 2012-03-15 17:50 actionmailer-3.2.2
drwxr-xr-x 3 root root 4096 2012-03-21 18:59 actionpack-3.2.2
drwxr-xr-x 3 root root 4096 2011-05-10 12:05 activemodel-3.0.6
drwxr-xr-x 3 root root 4096 2012-03-15 17:50 activemodel-3.2.2
drwxr-xr-x 4 root root 4096 2011-05-10 12:05 activerecord-3.0.6
drwxr-xr-x 4 root root 4096 2012-03-15 17:50 activerecord-3.2.2
drwxr-xr-x 4 root root 4096 2011-05-10 12:05 activeresource-3.0.6
drwxr-xr-x 4 root root 4096 2012-03-15 17:50 activeresource-3.2.2
drwxr-xr-x 3 root root 4096 2011-05-10 12:05 activesupport-3.0.6
drwxr-xr-x 3 root root 4096 2012-03-15 17:50 activesupport-3.2.2
drwxr-xr-x 4 root root 4096 2012-03-14 15:21 akami-1.0.0
drwxr-xr-x 4 root root 4096 2011-05-10 12:05 arel-2.0.9
drwxr-xr-x 4 root root 4096 2012-03-15 17:50 arel-3.0.2
drwxr-xr-x 6 root root 4096 2011-05-10 12:05 builder-2.1.2
drwxr-xr-x 5 root root 4096 2012-03-15 17:50 builder-3.0.0
drwxr-xr-x 2 root root 4096 2012-03-21 18:17 bundle-0.0.1
drwxr-xr-x 6 root root 4096 2012-03-21 18:39 bundler-1.1.2
drwxr-xr-x 4 root root 4096 2012-03-15 17:56 daemon_controller-1.0.0
drwxr-xr-x 5 root root 4096 2011-05-10 12:05 diff-lcs-1.1.2
drwxr-xr-x 10 root root 4096 2011-05-10 12:05 erubis-2.6.6
drwxr-xr-x 10 root root 4096 2012-03-15 17:50 erubis-2.7.0
drwxr-xr-x 5 root root 4096 2011-05-10 12:05 factory_girl-1.3.3
drwxr-xr-x 5 root root 4096 2012-03-15 17:56 fastthread-1.0.7
drwxr-xr-x 4 root root 4096 2012-03-14 15:21 gyoku-0.4.4
drwxr-xr-x 3 root root 4096 2012-03-15 17:50 hike-1.2.1
drwxr-xr-x 4 root root 4096 2012-03-14 15:21 httpi-0.9.6
drwxr-xr-x 5 root root 4096 2011-05-10 12:05 i18n-0.5.0
drwxr-xr-x 5 root root 4096 2012-03-15 17:50 i18n-0.6.0
drwxr-xr-x 4 root root 4096 2012-03-15 17:50 journey-1.0.3
drwxr-xr-x 10 root root 4096 2012-03-15 17:50 json-1.6.5
drwxr-xr-x 3 root root 4096 2012-03-14 15:35 libv8-3.3.10.4-x86-linux
drwxr-xr-x 3 root root 4096 2011-05-10 12:05 mail-2.2.19
drwxr-xr-x 3 root root 4096 2012-03-15 17:50 mail-2.4.4
drwxr-xr-x 4 root root 4096 2011-05-10 12:05 mime-types-1.16
drwxr-xr-x 4 root root 4096 2012-03-15 17:50 multi_json-1.1.0
drwxr-xr-x 7 root root 4096 2012-03-15 21:37 mysql-2.8.1
drwxr-xr-x 7 root root 4096 2011-05-10 12:05 nokogiri-1.4.4
drwxr-xr-x 5 root root 4096 2012-03-14 15:21 nori-1.1.0
drwxr-xr-x 14 root root 4096 2012-03-21 18:33 passenger-3.0.11
drwxr-xr-x 4 root root 4096 2011-05-10 12:05 polyglot-0.3.1
drwxr-xr-x 7 root root 4096 2011-05-08 23:16 rack-1.2.2
drwxr-xr-x 7 root root 4096 2012-03-16 20:59 rack-1.4.1
drwxr-xr-x 6 root root 4096 2012-03-15 17:50 rack-cache-1.2
drwxr-xr-x 3 root root 4096 2011-05-10 12:05 rack-mount-0.6.14
drwxr-xr-x 3 root root 4096 2012-03-15 17:50 rack-ssl-1.3.2
drwxr-xr-x 4 root root 4096 2011-05-10 12:05 rack-test-0.5.7
drwxr-xr-x 4 root root 4096 2012-03-15 17:50 rack-test-0.6.1
drwxr-xr-x 6 root root 4096 2012-03-15 21:37 radius-0.7.3
drwxr-xr-x 3 root root 4096 2011-05-10 12:05 rails-3.0.6
drwxr-xr-x 2 root root 4096 2012-03-15 17:50 rails-3.2.2
drwxr-xr-x 4 root root 4096 2011-05-10 12:05 railties-3.0.6
drwxr-xr-x 5 root root 4096 2012-03-15 17:50 railties-3.2.2
drwxr-xr-x 6 root root 4096 2011-05-10 12:05 rake-0.8.7
drwxr-xr-x 5 root root 4096 2012-03-15 17:50 rdoc-3.12
drwxr-xr-x 8 root root 4096 2011-05-10 12:05 RedCloth-4.2.5
drwxr-xr-x 3 root root 4096 2011-05-10 12:06 rspec-2.5.0
drwxr-xr-x 7 root root 4096 2011-05-10 12:05 rspec-core-2.5.2
drwxr-xr-x 5 root root 4096 2011-05-10 12:05 rspec-expectations-2.5.0
drwxr-xr-x 6 root root 4096 2011-05-10 12:05 rspec-mocks-2.5.0
drwxr-xr-x 6 root root 4096 2011-05-10 12:06 rspec-rails-2.5.0
drwxr-xr-x 4 root root 4096 2012-03-21 18:32 rvm-1.9.2
drwxr-xr-x 4 root root 4096 2012-03-14 15:37 savon-0.9.9
drwxr-xr-x 3 root root 4096 2012-03-15 17:50 sprockets-2.1.2
drwxr-xr-x 7 root root 4096 2011-05-10 12:06 sqlite3-ruby-1.2.5
drwxr-xr-x 8 root root 4096 2012-03-14 15:35 therubyracer-0.9.10
drwxr-xr-x 5 root root 4096 2011-05-10 12:05 thor-0.14.6
drwxr-xr-x 5 root root 4096 2012-03-15 17:50 tilt-1.3.3
drwxr-xr-x 7 root root 4096 2011-05-10 12:05 treetop-1.4.9
drwxr-xr-x 4 root root 4096 2011-05-10 12:05 tzinfo-0.3.27
drwxr-xr-x 4 root root 4096 2012-03-15 17:50 tzinfo-0.3.32
drwxr-xr-x 4 root root 4096 2012-03-14 15:21 wasabi-2.1.0
drwxr-xr-x 5 root root 4096 2012-03-16 19:11 webrick-1.3.1
First… paste in your file:
require ‘rubygems’
before another require’s:
+
Use
require ‘action_pack’
insted of deprecated call ‘actionpack’.
On 22 March 2012 20:45, Ruby U. [email protected] wrote:
require “action_pack”
./test.rb:6:in require': no such file to load -- action_pack (LoadError) from ./test.rb:6:in
’
What does
gem list
show?
Colin
Hi Alex,
I tried you suggestion. Still getting the same error.
#!/usr/bin/ruby1.9.2
#!/opt/framework3/ruby/bin/ruby -w
#!/usr/bin/ruby -w
require ‘rubygems’
require “cgi”
require “action_pack”
./test.rb:6:in require': no such file to load -- action_pack (LoadError) from ./test.rb:6:in
’
Heh… seems you have problem with RVM load?
As your RVM installed in systemwide maner
check that your $HOME/.bashrc
file have this line at the end:
source ‘/usr/local/rvm/scripts/rvm’
If not then add and reload terminal. Then…
- Navigate to folder with your script and type that:
rvm --create --rvmrc 1.9.3@test_sctipt
- Then install all needed gems
- And replace that:
#!/usr/bin/ruby1.9.2
#!/opt/framework3/ruby/bin/ruby -w
#!/usr/bin/ruby -w
with this one:
#!/usr/bin/env ruby
Here is the o/p of gem list. I re-installed ruby in a new path ( so the
paths are different from my earlier posts). But still has the same
issue.
#!/usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby -w
###!/usr/bin/ruby -w # copy of above binary
require ‘rubygems’
require ‘cgi’
require ‘actionpack’
ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [i686-linux]
gem -v
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/yaml.rb:56:in `<top
(required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your
ruby.
1.8.19
gem env
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/yaml.rb:56:in `<top
(required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your
ruby.
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.19
- RUBY VERSION: 1.9.3 (2012-02-16 patchlevel 125) [i686-linux]
- INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p125
- RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p125/bin
- RUBYGEMS PLATFORMS:
- GEM PATHS:
- /usr/local/rvm/gems/ruby-1.9.3-p125
- /usr/local/rvm/gems/ruby-1.9.3-p125@global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
gem list -d actionpack
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/yaml.rb:56:in `<top
(required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your
ruby.
*** LOCAL GEMS ***
actionpack (3.2.2)
Author: David Heinemeier H.
Homepage: http://www.rubyonrails.org
Installed at: /usr/local/rvm/gems/ruby-1.9.3-p125
Web-flow and rendering framework putting the VC in MVC (part of
Rails).
gem list -d action_pack
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/yaml.rb:56:in `<top
(required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your
ruby.
*** LOCAL GEMS ***
/var/www/ruby/test.rb
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
require': cannot load such file -- actionpack (LoadError) from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
require’
from /var/www/ruby/test.rb:8:in `’
Hi Alex, thanks a lot for some informative advice.
I tried those things. Still no luck
env | grep -i rvm
rvm_bin_path=/usr/local/rvm/bin
GEM_HOME=/usr/local/rvm/gems/ruby-1.9.3-p125
IRBRC=/usr/local/rvm/rubies/ruby-1.9.3-p125/.irbrc
MY_RUBY_HOME=/usr/local/rvm/rubies/ruby-1.9.3-p125
rvm_tar=tar
rvm_path=/usr/local/rvm
rvm_uname=Linux
rvm_prefix=/usr/local
PATH=/usr/local/rvm/gems/ruby-1.9.3-p125/bin:/usr/local/rvm/gems/ruby-1.9.3-p125@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p125/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/etc/alternatives/gem-bin
rvm_rvmrc_flag=1
rvm_version=1.10.3
rvm_ruby_string=ruby-1.9.3-p125
GEM_PATH=/usr/local/rvm/gems/ruby-1.9.3-p125:/usr/local/rvm/gems/ruby-1.9.3-p125@global
rvm_delete_flag=0
env | grep -i ruby
GEM_HOME=/usr/local/rvm/gems/ruby-1.9.3-p125
IRBRC=/usr/local/rvm/rubies/ruby-1.9.3-p125/.irbrc
MY_RUBY_HOME=/usr/local/rvm/rubies/ruby-1.9.3-p125
PATH=/usr/local/rvm/gems/ruby-1.9.3-p125/bin:/usr/local/rvm/gems/ruby-1.9.3-p125@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p125/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/etc/alternatives/gem-bin
PWD=/var/www/ruby
rvm_ruby_string=ruby-1.9.3-p125
GEM_PATH=/usr/local/rvm/gems/ruby-1.9.3-p125:/usr/local/rvm/gems/ruby-1.9.3-p125@global
RUBY_VERSION=ruby-1.9.3-p125
Ran rvm --create --rvmrc 1.9.3 to create .rvmrc file in the script’s
folder.
Changed to #!/usr/bin/env ruby
head -5 test.rb
#!/usr/bin/env ruby
require ‘rubygems’
require ‘cgi’
require ‘actionpack’
./test.rb
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
require': cannot load such file -- actionpack (LoadError) from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
require’
from ./test.rb:9:in `’
gem env
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/yaml.rb:56:in `<top
(required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your
ruby.
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.17
- RUBY VERSION: 1.9.3 (2012-02-16 patchlevel 125) [i686-linux]
- INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p125
- RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p125/bin
- RUBYGEMS PLATFORMS:
- GEM PATHS:
- /usr/local/rvm/gems/ruby-1.9.3-p125
- /usr/local/rvm/gems/ruby-1.9.3-p125@global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
Yes. actionpack is installed…
gem list -d actionpack
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/yaml.rb:56:in `<top
(required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your
ruby.
*** LOCAL GEMS ***
actionpack (3.2.2)
Author: David Heinemeier H.
Homepage: http://www.rubyonrails.org
Installed at: /usr/local/rvm/gems/ruby-1.9.3-p125
Web-flow and rendering framework putting the VC in MVC (part of
Rails).
gem list -d action_pack
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/yaml.rb:56:in `<top
(required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your
ruby.
*** LOCAL GEMS ***
Hi Alex,
changing it to require ‘action_pack’ worked.
But other gems has the same issue -
./test.rb
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
require': cannot load such file -- bundler (LoadError) from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
require’
from ./test.rb:8:in `’
gem list -d bundler
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/yaml.rb:56:in `<top
(required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your
ruby.
*** LOCAL GEMS ***
bundler (1.1.2)
Authors: André Arko, Terence Lee, Carl L., Yehuda K.
Rubyforge: http://rubyforge.org/projects/bundler
Homepage: http://gembundler.com
Installed at: /usr/local/rvm/gems/ruby-1.9.3-p125
The best way to manage your application's dependencies
Hmm…
What gives this command?
rvm current
Have you tried require commands from ruby console(irb) ?
Hi Alex,
I was able to solve the issue. Don’t know what was wrong, but I removed
ruby, gems, rails, rvm completely from the machine. Rebooted and
installed everything freshly. That worked, now no more errors in loading
any gem.
thanks for your help