I have installed ruby and gems with sudo,
Whenever I run the script, I have to do it with sudo or else I will get this error:
/usr/local/rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- watir-webdriver (LoadError)
from /usr/local/rvm/rubies/ruby-1.9.3-p385/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'from Login.rb:1:in `<main>'
I am planning to use eclipse IDE, so--if I do run the script in eclipse--I get the same problem
Could someone help me in running ruby script as superuser in eclipse?
You can change the access permissions for needed gem.
sudo chmod 644 filename
To know the full path:
gem which gemname
Related
Found today I couldn't get my 'jekyll server' to start, so I preceded to reinstall 'jekyll' but I get this error...
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Then I tried 'sudo gem install jekyll' and it worked!
Can anyone explain what's going on?
Thanks!
Use rbenv to setup a ruby binary that is in your home dir (a writable path).
You get that error because you lack write permissions to the System dir. Don't try to get write perms there - that's just asking for trouble. Instead, install a ruby version manager.
rbenv is linked above. Some like RVM. You can google for the arguments that pro/con each. rbenv is "more unix-like" and that is a good reason on its own.
It is installing system wide , you can force a single user install as follow
gem install jekyll --user-install
Hi People I am trying to install a gem file through command prompt on MAC using the following command "gem install filename" but whenever I try to execute the command I get the following error
WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have /Users/hemmanshu/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
ERROR: Error installing frank-cucumber-0.8.14:
cucumber requires gherkin (~> 2.10.0, runtime)
every time I try to execute this command the same thing pops up.
You need to install gems with superuser privileges so you should to use
sudo gem install [gemname]
instead of
gem install [gemname]
U try with sudo. like "sudo gem install filename"
...Most of the time this is a PATH issue, Suppose you are using zshell as me, then add this line at the end of ~/.zshrc file
export PATH="$PATH:$HOME/.gem/ruby/2.1.0/bin"
If you are using bash as default shell then add this line to end of ~/.bashrc file
export PATH="$PATH:$HOME/.gem/ruby/2.1.0/bin"
For your case it will be like this:
export PATH="$PATH:$HOME/.gem/ruby/1.8/bin
Lastly don't forget to reload the shell by source ~/.zshrc incase of z-shell or source ~/.bashrc incase of bash-shell. I think this helps someone.
I have made a script that is already working properly in my development environment with RVM. This script reads *.eml files and parses them.
Now, my problem is this. When I transfer it to the production server, it gives a Permission denied - filename.eml (Errno::EACCES) when reading some files. When I manually read these files using sudo nano filename.eml, it is readable so I thought running my ruby script with sudo is the answer.
But when I tried running it with sudo ruby scriptname.rb, this time it gives me a cannot load such file -- mail (LoadError).
The mail gem is clearly installed and is shown both in gem list --local and sudo gem list --local.
The ruby versions are identical with or without sudo (1.9.3).
The mail gem is also accessible using sudo irb then typing require 'mail'.
Both development and production environments are on a Mac OS with RVM-managed ruby versions.
Any help will be greatly appreciated. Thanks.
maybe the gem is not readable for your server user, such as 'wwwroot', so please make sure the file is 775 mode. e.g.
cd $GEM_HOME
sudo chmod 755 -R .
then everything is readable for other group's users.
I'm trying to run the ruby gem "mongo3" (http://mongo3.com/)
I'm new to gem, but I would think that running "gem mongo3" should execute it, but I get this error:
chris#Zombie:~$ gem mongo3
ERROR: While executing gem ... (RuntimeError)
Unknown command mongo3
So I did "gem which mongo3" and it said it is located at "/var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb". I then ran "ruby /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb" with the following result:
chris#Zombie:~$ ruby /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb
/var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3/node.rb:1:in `require': no such file to load -- json (LoadError)
from /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3/node.rb:1
from /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb:41:in `require'
from /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb:41:in `require_all_libs_relative_to'
from /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb:41:in `each'
from /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb:41:in `require_all_libs_relative_to'
from /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb:53
I'm not sure what I'm doing wrong - I suspect that ruby and gems are confused about where the gems should be loaded from or something. Thanks!
You don't need to do a gem mongo3 or ruby /var/lib/gems/1.8/gems/mongo3-0.1.3/lib/mongo3.rb. Instead, just simply run mongo3.
Make sure to follow the usage instructions here to configure it or you'll get runtime errors.
Edit: If you don't install the gem using sudo, then you won't have proper write access to /usr/bin, meaning the mongo3 executable will not be in your path. You'll probably see a warning like this when installing:
WARNING: Installing to ~/.gem since /var/lib/gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have /home/chris/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
You have two options: install the gem using sudo gem install mongo3 so it properly links to /usr/bin, or add /home/chris/.gem/ruby/1.8/bin to your path.
I'm trying to run a ruby file which imports a gem. The ya2yaml gem is installed, yet somehow it is not found:
$ cat delme.rb
require 'rubygems'
require 'ya2yaml'
$ ruby delme.rb
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- ya2yaml (LoadError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from delme.rb:2
I installed the gem using: sudo gem install ya2yaml and I know that the gem is actually installed:
$ gem list --local | grep ya2yaml
ya2yaml (0.26)
Also, the following works from a rails program I just downloaded:
sudo rake gems
However the following fails:rake gems
Which leads me to think that there may be a permissions problem somewhere.
Why can't the gem be found? What can I do to diagnose this?
Thanks!
The thing I would do in a situation like this:
Search for the gem's location on your system. Use this command:
find / -name ya2yaml
Check that the found directory is added to your PATH system variable by doing this:
echo $PATH
If the path where ya2yaml gem is located is not listed in the PATH variable's value, add it:
PATH=$PATH:/gem/location/directory
export PATH
I hope you'll find these steps helpful. Good luck!
Instead of require 'rubygems' inside delme.rb, try starting ruby with -rubygems:
$ ruby -rubygems delme.rb
I've certainly seen this error before. Unfortunately I don't know what causes it. I do know that if you see it on Linux and you've installed gem via your package manager (synaptic / yum / etc) then you can generally fix it by installing gem by hand from their website. The instructions there are pretty straight-forward.
(Your command line looks unix-y, so it seems to me that you may be on Linux. If you're on a Mac, it's certainly worth trying anyway.)
UPDATE: Linux, then. Ta.