Permission error on shared host for gem command - ruby-on-rails

I'm getting an error each time I attempt to use gem install sass (or gem install anything, really).
/usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:91:in `read': Permission denied - /usr/lib/ruby/gems/1.8/specifications/passenger-3.0.18.gemspec (Errno::EACCES)
from /usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:91:in `load_specification'
from /usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:153:in `load_gems_in'
from /usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:152:in `each'
from /usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:152:in `load_gems_in'
from /usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:149:in `reverse_each'
from /usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:149:in `load_gems_in'
from /usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:345:in `refresh!'
from /usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:78:in `from_gems_in'
from /usr/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:58:in `from_installed_gems'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:883:in `source_index'
from /usr/lib/ruby/site_ruby/1.8/rubygems/gem_path_searcher.rb:81:in `init_gemspecs'
from /usr/lib/ruby/site_ruby/1.8/rubygems/gem_path_searcher.rb:13:in `initialize'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:841:in `new'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:841:in `searcher'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:840:in `synchronize'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:840:in `searcher'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:479:in `find_files'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:983:in `load_plugins'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1139
from /usr/bin/gem:8:in `require'
from /usr/bin/gem:8
Because this is a shared host, I don't have access to /usr/lib/ruby. I contacted a2hosting but they told me they don't support Ruby on Rails and to post about it here. So I guess that's an indication that there is some way to fix it myself? There is a RubyGems app on the a2hosting CPanel, but it doesn't work either:
I suspect this is because it just uses the same commands I'm using, and thus throws the same error.
I have installed rvm on the server, however. Perhaps there is a workaround using that?

Related

Unable to launch rails due to "'executable-hooks (= 1.6.0)' (Gem::UnsatisfiableDependencyError)"

Have had this error for a couple of weeks now and keep giving up trying to solve it, forget about it and then rediscover it. The cycle of pain has been killing me.
/Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems/resolver.rb:231:in `search_for': Unable to resolve dependency: user requested 'executable-hooks (= 1.6.0)' (Gem::UnsatisfiableDependencyError)
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems/resolver.rb:283:in `block in sort_dependencies'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems/resolver.rb:277:in `each'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems/resolver.rb:277:in `sort_by'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems/resolver.rb:277:in `with_index'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems/resolver.rb:277:in `sort_dependencies'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb:52:in `block in sort_dependencies'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb:69:in `with_no_such_dependency_error_handling'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb:51:in `sort_dependencies'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems/resolver/molinillo/lib/molinillo/resolution.rb:165:in `initial_state'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems/resolver/molinillo/lib/molinillo/resolution.rb:106:in `start_resolution'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems/resolver/molinillo/lib/molinillo/resolution.rb:64:in `resolve'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems/resolver/molinillo/lib/molinillo/resolver.rb:42:in `resolve'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems/resolver.rb:188:in `resolve'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems/request_set.rb:396:in `resolve'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems/request_set.rb:408:in `resolve_current'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems.rb:243:in `finish_resolve'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems.rb:311:in `block in activate_bin_path'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems.rb:309:in `synchronize'
from /Users/Samudabamu/.rvm/rubies/ruby-2.1.10/lib/ruby/site_ruby/2.1.0/rubygems.rb:309:in `activate_bin_path'
from /Users/Samudabamu/.rvm/gems/ruby-2.1.10/bin/rails:23:in `<main>'
from /Users/Samudabamu/.rvm/gems/ruby-2.1.10/bin/ruby_executable_hooks:24:in `eval'
from /Users/Samudabamu/.rvm/gems/ruby-2.1.10/bin/ruby_executable_hooks:24:in `<main>'
I've tried completely purging ruby version manager(rvm), reinstalling bundler, xcode, openssl amongst other things. Could this potentially be a $PATH problem? Really clutching at straws here.
Thanks for your time.
Just letting the community know that I never resolved this. I ended up doing a fresh install of OSX to circumnavigate the problem, which is definitely NOT the best solution.
My expedient workaround for this is to uninstall executable-hooks (good enough for my use case, but may introduce other issues — use with caution):
% solargraph -v
# ~/.asdf/installs/ruby/3.0.3/lib/ruby/3.0.0/rubygems.rb:278:in `find_spec_for_exe': can't find gem solargraph (>= 0.a) with executable solargraph (Gem::GemNotFoundException)
# ~/.asdf/installs/ruby/3.0.3/lib/ruby/3.0.0/rubygems.rb:297:in `activate_bin_path'
# ~/.asdf/installs/ruby/3.0.3/bin/solargraph:25:in `<main>'
# ~/.asdf/installs/ruby/3.0.3/bin/ruby_executable_hooks:22:in `eval'
# ~/.asdf/installs/ruby/3.0.3/bin/ruby_executable_hooks:22:in `<main>'
% gem uninstall executable hooks
% solargraph -v
# 0.48.0

Ruby on rails on Jailed shell cpanel on centos

I am trying to install ruby on rails on a shared server with Cpanel with Jailed Shell on SSH.
I've this
-jailshell: rbenv: command not found
when server is starting.
After downloading the Ruby tar package, I navigated inside the folder and ran the commands,
make
and
make install
and
./configure --prefix=/usr/local/ruby -exec-prefix=/usr/local/ruby
once and it didn't work
tried even this
./configure --prefix=/usr/local/ -exec-prefix=/usr/local/
the command make install results in the following
Permission denied # dir_s_mkdir - /usr/local/ruby (Errno::EACCES)
from /home/username/ruby-2.1.1/lib/fileutils.rb:247:in `fu_mkdir'
from /home/username/ruby-2.1.1/lib/fileutils.rb:224:in `block (2 levels) in mkdir_p'
from /home/username/ruby-2.1.1/lib/fileutils.rb:222:in `reverse_each'
from /home/username/ruby-2.1.1/lib/fileutils.rb:222:in `block in mkdir_p'
from /home/username/ruby-2.1.1/lib/fileutils.rb:208:in `each'
from /home/username/ruby-2.1.1/lib/fileutils.rb:208:in `mkdir_p'
from ./tool/rbinstall.rb:193:in `makedirs'
from ./tool/rbinstall.rb:300:in `prepare'
from ./tool/rbinstall.rb:339:in `block in <main>'
from ./tool/rbinstall.rb:789:in `call'
from ./tool/rbinstall.rb:789:in `block in <main>'
from ./tool/rbinstall.rb:786:in `each'
from ./tool/rbinstall.rb:786:in `<main>'
make: *** [do-install-all] Error 1
My service provider says it's the max level of access he can give me.
Tried installing it from CPANEL Ruby on rails installation. No luck from there either.
Any workarounds to install ruby, rvm and rails?
Thanks.
P.S. Tried a lot of methods posted online, no luck.

Rails server error - railties

After finishing the official getting started guide for RoR I played with it so much that I ruined the blog so I decided just to scrap everything and start again.
Now that I'm trying to run the rails server I get this error
/home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor/actions.rb:109:in `expand_path': No such file or directory - getcwd (Errno::ENOENT)
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor/actions.rb:109:in `destination_root='
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor/actions.rb:85:in `initialize'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/cli.rb:17:in `initialize'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor.rb:359:in `new'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor.rb:359:in `dispatch'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/vendor/thor/base.rb:440:in `start'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/cli.rb:10:in `start'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/bin/bundle:20:in `block in <top (required)>'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/friendly_errors.rb:5:in `with_friendly_errors'
from /home/nadia/.gem/ruby/2.0.0/gems/bundler-1.5.2/bin/bundle:20:in `<top (required)>'
from /home/nadia/.gem/ruby/2.0.0/bin/bundle:23:in `load'
from /home/nadia/.gem/ruby/2.0.0/bin/bundle:23:in `<main>'
in the gemfile I have added
gem 'railties', '~>4.0.2'
then
$ bundle install
to try and resolve the issue. However it still hasn't work. I'm fairly new so I'm not actually sure what the error is.
Any thoughts would be appreciated.
I'm also running rails v4.0.2 if that helps
This is a pretty weird thing to see:
No such file or directory - getcwd (Errno::ENOENT)
Are you trying to run this application from a directory you maybe moved, or even deleted? That error implies that it can't determine the current directory.
Define rails in gem file like this
gem 'rails', '4.0.2'
And then bundle install.
Whoops. I derped. All sorted now. I was simply trying to run it from the wrong directory.
Should have seen it earlier.

Ruby on Rails (Errno::EACCES)

I am getting the following error whenever I type any command on all my rails applications. I working on a virtual machine in cloud 9. Any idea or guidance?
(master) $ bundle exec rspec spec/
/opt/rh/ruby193/root/usr/share/rubygems/rubygems/specification.rb:541:in `read': Permission denied - /usr/libexec/openshift/cartridges/c9-0.1/root/lib/ruby/gems/specifications/multi_json-1.8.4.gemspec (Errno::EACCES)
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/specification.rb:541:in `load'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/specification.rb:269:in `block (2 levels) in _all'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/specification.rb:268:in `each'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/specification.rb:268:in `block in _all'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/specification.rb:267:in `each'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/specification.rb:267:in `_all'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/specification.rb:410:in `each'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/dependency.rb:216:in `find_all'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/dependency.rb:216:in `matching_specs'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/dependency.rb:238:in `to_specs'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/dependency.rb:256:in `to_spec'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems.rb:1231:in `gem'
from /usr/libexec/openshift/cartridges/c9-0.1/root/lib/ruby/gems/bin/bundle:22:in `<main>'
It sounds like your gems were installed with sudo access, which your current user (web runner?) lack the right perms to see the Ruby install dir.
I can't quite say why the gems were installed to a path like /usr/libexec/openshift/cartridges — perhaps this is part of your cloud host's setup?
Do you boot your own rails server out of your instance? e.g. like you installed Unicorn, nginx, etc. on your own? If so, you can use rbenv to install a ruby and gemset to a local path over which you have full permission control.
If you don't have scenario #1 above, then the setup may be misconfigured by the host, and you should open a ticket.

RoR Bundler problem

I installed everything from the bottom up and thought it was working fine until I ran a bundle install
Has anyone ever seen this? Any ideas? Please help. Thanks.
bundle install
Fetching source index for http://rubygems.org/
/usr/local/lib/ruby/1.9.1/rubygems/format.rb:38:in `from_file_by_path': Cannot load gem at [/usr/local/lib/ruby/gems/1.9.1/cache/rake-0.8.7.gem] in /home/ec2-user/anotherApp (Gem::Exception)
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/source.rb:73:in `fetch'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/installer.rb:45:in `block in run'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `block in each'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/installer.rb:44:in `run'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/installer.rb:8:in `install'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/cli.rb:226:in `install'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/vendor/thor/task.rb:22:in `run'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/vendor/thor/base.rb:389:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/bin/bundle:13:in `<top (required)>'
from /usr/local/bin/bundle:19:in `load'
from /usr/local/bin/bundle:19:in `<main>'
If you install Ruby 1.9.2-x from source it still installs the gems to /usr/local/lib/ruby/gems/1.9.1/... which is a bit of a WTF (relevant). I too got this error but it can also be caused by a permissions issue. So try running the command again as root (assuming you're running into this on a *nix system). Yes, that is not ideal however you may find it works and at least you can keep on going on the path to figuring things out (and it's all in a test VM anyway, right?).
It's not recommended to use Ruby 1.9.1 with Rails. Better 1.8.7 or 1.9.2, see http://rubyonrails.org/download. Looks like you use the Debian/Ubuntu Ruby. 1.8.7 is available and usable in Debian/Ubuntu, install the ruby-full meta package via apt. Or compile Ruby 1.9.2 directly or via the Ruby Version Manager (rvm). Do not install rubygems via apt.

Resources