Ruby on Rails (Errno::EACCES) - ruby-on-rails

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.

Related

Installing Ruby on Godaddy Shared Hosting

I'm trying to use Linuxbrew to manage my dependencies; however, when I attempt to install I receive an error.
Error: No such file or directory - /usr/local/bin/rub
I have attempted to install using the source files and running
./configur-prefix=$Home/env
make
make install
which gives the following report:
installing binary commands: /env/bin
/home/tmiles199/downloads/ruby-2.4.1/lib/fileutils.rb:226:in `mkdir': Permission denied # dir_s_mkdir - /env (Errno::EACCES)
from /home/tmiles199/downloads/ruby-2.4.1/lib/fileutils.rb:226:in `fu_mkdir'
from /home/tmiles199/downloads/ruby-2.4.1/lib/fileutils.rb:207:in `block (2 levels) in mkdir_p'
from /home/tmiles199/downloads/ruby-2.4.1/lib/fileutils.rb:205:in `reverse_each'
from /home/tmiles199/downloads/ruby-2.4.1/lib/fileutils.rb:205:in `block in mkdir_p'
from /home/tmiles199/downloads/ruby-2.4.1/lib/fileutils.rb:191:in `each'
from /home/tmiles199/downloads/ruby-2.4.1/lib/fileutils.rb:191:in `mkdir_p'
from ./tool/rbinstall.rb:194:in `makedirs'
from ./tool/rbinstall.rb:306:in `prepare'
from ./tool/rbinstall.rb:344:in `block in <main>'
from ./tool/rbinstall.rb:822:in `block in <main>'
from ./tool/rbinstall.rb:819:in `each'
from ./tool/rbinstall.rb:819:in `<main>'
make: *** [do-install-all] Error 1
Godaddy does not allow sudo or su access. The server info
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17)
I need Homebrew to install xz and glibc before I can install Ruby, or update the gcc version. Unfortunately, both produce the first error.
Could anyone help me install this package? My real endgoal is updating gcc through brew.
You don't have needed permissions to do that in the shared hosting:
in `mkdir': Permission denied # dir_s_mkdir - /env (Errno::EACCES)
When you try to create the directory, the installation fails.
You need a VPS, a dedicated server or a shared hosting preconfigurated.
I have found out a workaround for this issue to be able to install homebrew without root and sudo access.
Just follow the instruction on the Alternative Installation section of brew.sh and it will wonderfully work with no mayor issues at all.
This option will not work if you do not meet the minimum requirements regarding the glibc version.

Permission error on shared host for gem command

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?

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.

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.

First time rails install, help with gems/rake

I just did a first time ruby enterprise edition, installed some gems, and now I'm trying to do a
' sudo ./rake gems:install' and getting a:
rake aborted!
No Rakefile found
error. Firstly, what directory should I be doing this from?
Here are the steps I've followed:
download ruby enterprise from http://www.rubyenterpriseedition.com/download.html
wget http://rubyforge.org/frs/download.php/68719/ruby-enterprise-1.8.7-2010.01.tar.gz
./ruby-enterprise-X.X.X/installer
/opt/ruby-enterprise-1.8.7-2010.01/bin/gem install mysql
ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/gem /usr/bin/gem
ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/rake /usr/bin/rake
and I've installed several gems
I have found the appropriate directory (I think), and am still getting errors. Here's a copy of rake with --trace:
dan#dev:~/myApp.com-ror$ rake --trace gems:install
(in /home/dan/myApp.com-ror)
** Invoke gems:install (first_time)
** Invoke gems:base (first_time)
** Execute gems:base
** Invoke environment (first_time)
** Execute environment
rake aborted!
No such file or directory - /home/dan/myApp.com-ror/config/database.yml
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:902:in `read'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:902:in `database_configuration'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:437:in `initialize_database'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:141:in `process'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `send'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `run'
/home/dan/songness.com-ror/config/environment.rb:14
/home/dan/Languages/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/home/dan/Languages/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/misc.rake:4
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/home/dan/Languages/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/gems.rake:17
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/home/dan/Languages/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/home/dan/Languages/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/home/dan/Languages/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
And what should database.yml look like?
rake gems:install is to install gems for your app. You have to run this inside your app root directory. To install gems on your machine use gem install.
If you have not set your path up correctly then you will need to run this from the rails directory.
Ok I've looked in the docs
$ /opt/ruby-enterprise-X.X.X/bin/gem install rails
in your case means just:
gem install rails
When you mentioned ' sudo ./rake gems:install' what were you trying to achieve?
Once installed rails do:
rails myproject
And there you go.
Presuming you're not using bundler or can't (due to your ruby/rails version)...
Below, I'm avoiding the sudo prepend because RoR is no longer the sole realm of linux users. Windows users using gitbash as our low level console for administering our Rails apps in the local development environment will not need sudo, nor will it work in our development environment. FTR, if you don't know what sudo is, it means "super user do", a leftover from unix and so an intrinsic part of the linux vernacular. If you need to do things in linux that require privilege, you'll probably need sudo to gain those rights (or you'll need to assign direct super user status to yourself for particular actions....sometimes sudo isn't enough!). If you need privilege in windows, you probably have already logged into windows with administrative rights.. In any case, if you're new to Ruby on Rails and are confounded by the term, just ignore it for now. You don't need it, although you probably will at some point when you start interacting with hosting services, which often run within a linux framework...
Anyway, getting back to the matter at hand...
gem install (some gem name) (ex: gem install tinyMCE) installs a copy to your local Ruby development environment. That is, think of it as installing a library component you can call on later. In general, it does nothing to our application on its own.
But if you want to use a gem (a second source enhancement package, ex: tinyMCE, a popular rich text editor enhancement) then the gem will need to be installed directly to your application, or said another way, you'll need to bind a transportable copy to the application AFTER installing it to your rails development environment, whetherr modifying an existing application or creating a new one.
If you're still puzzled, suppose I say it this way
you create an application like "My_special_blog". The action Rails My_special_blog creates the basic plumbing, but it doesn't write the content, nor does it automatically install tinyMCE so you can use it, even though you may have installed it to your development system (using gem install tinyMCE ), ie, your RUBY installation. Gems are an easy way of adding functionality like the aforementioned rich text editor
And that's exactly what rake:gems install does. It uses your application's environment.rb file (in the My_special_blog/config subdirectory btw) to determine which gems are wanted for use by the application, then it installs them to the application (literally, in subdirectories off the My_special_blog/vendors directory from the local development environment.
The important thing is that when you run rake:gems install, you need to do so from the "root" of your application, ie, from the My_special_blog directory. Not the ruby directory, not My_special_blog/config, just My_special_blog (as an example application name)
As a leader for you to do a bit of googling...Version and source location can be specified in the environment.rb's config.gem statements that define which gems you're going to use.
Hope this helps someone, who like me, is often confounded by terse answers that presume one is already expert enough that the question wouldn't have been asked in the first place...
If you look at environment.rb, it should have an entry like this
Rails::Initializer.run do |config|
end
it's inside that initializer that you place gem config statements. For instance, let's say you wanted to add the clearance gem and you needed v0.5.3 and the gem was located at gems.github.com...and you also wanted mislav-will paginate, the syntax might look a bit like this:
Rails::Initializer.run do |config|
config.gem "thoughtbot-clearance",
:lib => 'clearance',
:source => 'http://gems.github.com',
:version => '0.5.3'
config 'mislav-will_paginate',
:version => '~> 2.3.8',
:lib => 'will_paginate',
:source => 'http://gems.github.com'
end
without those statements, rake:gems install won't load local copies of those gems to your application's vendor/gems folder.

Resources