rake not possible on GCE - permission error - ruby-on-rails

I'm logged into the GCE console and copied my rails app onto the server (tried both var/www and my home directory just to be sure). Connected via gcloud auth login and gcloud compute ssh to my instance as the same user that is owning the project.
Once I'm in the rails directory:
-bundle install works
- rake comes up with this error:
/usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/fileutils.rb:250:in `mkdir': Permission denied # dir_s_mkdir - /usr/local/rvm/gems/ruby-2.1.1/extensions/x86_64-linux/2.1.0/bcrypt-3.1.7 (Errno::EACCES)
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/fileutils.rb:250:in `fu_mkdir'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/fileutils.rb:224:in `block (2 levels) in mkdir_p'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/fileutils.rb:222:in `reverse_each'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/fileutils.rb:222:in `block in mkdir_p'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/fileutils.rb:208:in `each'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/fileutils.rb:208:in `mkdir_p'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/ext/builder.rb:210:in `write_gem_make_out'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/ext/builder.rb:132:in `build_error'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/ext/builder.rb:171:in `rescue in build_extension'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/ext/builder.rb:156:in `build_extension'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/ext/builder.rb:198:in `block in build_extensions'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/ext/builder.rb:195:in `each'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/ext/builder.rb:195:in `build_extensions'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/specification.rb:1436:in `block in build_extensions'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/user_interaction.rb:45:in `use_ui'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/specification.rb:1434:in `build_extensions'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/stub_specification.rb:60:in `build_extensions'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/basic_specification.rb:56:in `contains_requirable_file?'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/specification.rb:925:in `block in find_inactive_by_path'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/specification.rb:924:in `each'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/specification.rb:924:in `find'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/specification.rb:924:in `find_inactive_by_path'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems.rb:185:in `try_activate'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:132:in `rescue in require'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from /usr/local/rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:9:in `<main>'
When I try sudo rake:
sudo: rake: command not found
any ideas? I'm totally lost with this, cant find any place to set permissions or something similar.

Please try this instead:
$ rvmsudo rake ...
Plase see also:
rvmsudo vs sudo?

Here's what worked for me:
sudo chown -R $USER /usr/local/
Rake can then be run without issues.

Related

Unicorn start up issue

I cant figure out whats wrong with Unicorn, it doesnt want to start up. Any help is appreciated
ubuntu#ip-172-31-15-195:~/www/tf/current$ RAILS_ENV=production bundle exec unicorn_rails -c config/unicorn.rb -D
bundler: failed to load command: unicorn_rails (/home/ubuntu/www/tf/shared/bundle/ruby/2.3.0/bin/unicorn_rails)
Errno::EEXIST: File exists # dir_s_mkdir - tmp/pids
/usr/local/lib/ruby/2.3.0/fileutils.rb:254:in `mkdir'
/usr/local/lib/ruby/2.3.0/fileutils.rb:254:in `fu_mkdir'
/usr/local/lib/ruby/2.3.0/fileutils.rb:228:in `block (2 levels) in mkdir_p'
/usr/local/lib/ruby/2.3.0/fileutils.rb:226:in `reverse_each'
/usr/local/lib/ruby/2.3.0/fileutils.rb:226:in `block in mkdir_p'
/usr/local/lib/ruby/2.3.0/fileutils.rb:211:in `each'
/usr/local/lib/ruby/2.3.0/fileutils.rb:211:in `mkdir_p'
/home/ubuntu/www/tf/shared/bundle/ruby/2.3.0/gems/unicorn-5.0.1/bin/unicorn_rails:202:in `block in <top (required)>'
/home/ubuntu/www/tf/shared/bundle/ruby/2.3.0/gems/unicorn-5.0.1/lib/unicorn/configurator.rb:80:in `reload'
/home/ubuntu/www/tf/shared/bundle/ruby/2.3.0/gems/unicorn-5.0.1/lib/unicorn/configurator.rb:65:in `initialize'
/home/ubuntu/www/tf/shared/bundle/ruby/2.3.0/gems/unicorn-5.0.1/lib/unicorn/http_server.rb:76:in `new'
/home/ubuntu/www/tf/shared/bundle/ruby/2.3.0/gems/unicorn-5.0.1/lib/unicorn/http_server.rb:76:in `initialize'
/home/ubuntu/www/tf/shared/bundle/ruby/2.3.0/gems/unicorn-5.0.1/bin/unicorn_rails:209:in `new'
/home/ubuntu/www/tf/shared/bundle/ruby/2.3.0/gems/unicorn-5.0.1/bin/unicorn_rails:209:in `<top (required)>'
/home/ubuntu/www/tf/shared/bundle/ruby/2.3.0/bin/unicorn_rails:22:in `load'
/home/ubuntu/www/tf/shared/bundle/ruby/2.3.0/bin/unicorn_rails:22:in `<top (required)>'
master failed to start, check stderr log for details
You have symbolic link ~www/tf/current/tmp/pids present but its target directory ~www/tf/shared/pids/ doesn't exist so the link is broken. unicorn is attempting to create tmp/pids directory in the ~www/tf/current/ but the symbolic link which already exists causes failure.
To fix this you need to create ~www/tf/shared/pids/ directory with appropriate ownership and permissions.

Cannot launch rails app: ERROR: Failed to build gem native extension. deadlock; recursive locking

I'm trying to launch my rails app on VirtualBox Ubuntu 14.04, but for some reason every time I use any rails or gem command like rails s or bundle install I get the following error message:
/home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/ext/builder.rb:159:in `synchronize': ERROR: Failed to build gem native extension. (Gem::Ext::BuildError)
ERROR: Failed to build gem native extension.
deadlock; recursive locking
Gem files will remain installed in /home/jakup/.rvm/gems/ruby-2.2.4#global/gems/gem-wrappers-1.2.7 for inspection.
Results logged to /home/jakup/.rvm/gems/ruby-2.2.4#global/extensions/x86_64-linux/2.2.0-static/gem-wrappers-1.2.7/gem_make.out
Gem files will remain installed in /home/jakup/.rvm/gems/ruby-2.2.4/gems/nokogiri-1.6.7.2 for inspection.
Results logged to /home/jakup/.rvm/gems/ruby-2.2.4/extensions/x86_64-linux/2.2.0-static/nokogiri-1.6.7.2/gem_make.out
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/ext/builder.rb:159:in `build_extension'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/ext/builder.rb:198:in `block in build_extensions'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/ext/builder.rb:195:in `each'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/ext/builder.rb:195:in `build_extensions'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:1436:in `block in build_extensions'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/user_interaction.rb:45:in `use_ui'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:1434:in `build_extensions'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/stub_specification.rb:60:in `build_extensions'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/basic_specification.rb:56:in `contains_requirable_file?'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:925:in `block in find_inactive_by_path'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:924:in `each'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:924:in `find'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:924:in `find_inactive_by_path'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems.rb:185:in `try_activate'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:132:in `rescue in require'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from /home/jakup/.rvm/gems/ruby-2.2.4/gems/psych-2.0.17/lib/psych.rb:6:in `<top (required)>'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems.rb:601:in `load_yaml'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/config_file.rb:327:in `load_file'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/config_file.rb:196:in `initialize'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems.rb:289:in `new'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems.rb:289:in `configuration'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/ext/builder.rb:63:in `run'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/ext/ext_conf_builder.rb:37:in `block in build'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/2.2.0/tempfile.rb:319:in `open'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/ext/ext_conf_builder.rb:17:in `build'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/ext/builder.rb:161:in `block (2 levels) in build_extension'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/ext/builder.rb:160:in `chdir'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/ext/builder.rb:160:in `block in build_extension'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/ext/builder.rb:159:in `synchronize'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/ext/builder.rb:159:in `build_extension'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/ext/builder.rb:198:in `block in build_extensions'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/ext/builder.rb:195:in `each'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/ext/builder.rb:195:in `build_extensions'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:1436:in `block in build_extensions'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/user_interaction.rb:45:in `use_ui'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/specification.rb:1434:in `build_extensions'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/stub_specification.rb:60:in `build_extensions'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/basic_specification.rb:56:in `contains_requirable_file?'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:68:in `block in require'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:67:in `each'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:67:in `find'
from /home/jakup/.rbenv/versions/2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:67:in `require'
from /home/jakup/.rvm/gems/ruby-2.2.4/gems/railties-4.2.6/bin/rails:9:in `<top (required)>'
from /home/jakup/.rbenv/versions/2.2.3/bin/rails:23:in `load'
from /home/jakup/.rbenv/versions/2.2.3/bin/rails:23:in `<main>'
I used to have this error in the past when I set my network adapter to bridged network on VirtualBox, but now this error occurs even when I'm not on bridged network, any ideas?
I will write in a form of a answer just to easier write.
Thy to delete all previously installed gems (e.g. delete the gems manually) and try to re-install them. It should be working then.
Don't delete these (ignore the versions of the gems):
rake (10.4.2)
rdoc (4.2.1)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
gem-wrappers (1.2.7)
bundler (1.11.2)
bundler-unload (1.0.2)
Also, try to install gems inside .bundle directory not in a global namespace. Install it at first like bundle install --path .bundle, and I think every next time it will be using that directory
I found a (temporary?) solution..
I was running the project from a shared folder between windows (host) and ubuntu (guest in virtualbox) for some reason when I run the project locally, so not within the shared folder and I unmount the folder, it works.
Don't ask me the details of why it works, it just magically does for some reason.

Cap aborted SSHKit error

I am trying to deploy my rails app with capistrano and I am getting the following error after the command:
cap production deploy
Output:
DEBUG[a3e9636c] Running /usr/bin/env [ -d ~/.rvm ] on handco-op.com
DEBUG[a3e9636c] Command: [ -d ~/.rvm ]
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host appname.com: Authentication failed for user deploy#appname.com
/home/deploy/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.1/lib/net/ssh.rb:219:in `start'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/connection_pool.rb:50:in `call'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/connection_pool.rb:50:in `create_new_entry'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/connection_pool.rb:22:in `checkout'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:179:in `with_ssh'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:131:in `block in _execute'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `tap'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `_execute'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:62:in `test'
/home/deploy/.rvm/gems/ruby-2.1.2/bundler/gems/rvm-dc35ec5e7a74/lib/capistrano/tasks/rvm.rake:19:in `block (3 levels) in <top (required)>'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Net::SSH::AuthenticationFailed: Authentication failed for user deploy#appname.com
/home/deploy/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.1/lib/net/ssh.rb:219:in `start'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/connection_pool.rb:50:in `call'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/connection_pool.rb:50:in `create_new_entry'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/connection_pool.rb:22:in `checkout'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:179:in `with_ssh'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:131:in `block in _execute'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `tap'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `_execute'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:62:in `test'
/home/deploy/.rvm/gems/ruby-2.1.2/bundler/gems/rvm-dc35ec5e7a74/lib/capistrano/tasks/rvm.rake:19:in `block (3 levels) in <top (required)>'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/home/deploy/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => rvm:hook
(See full trace by running task with --trace)
Just to be clear, I replaced my real server name with "appname" to stay secret;) Thanks for any advice! I hope it is a simple fix and I will keep looking into the error as well.
I was missing secret keys, had to set up nopassword ssh and a lot of other tweaks. It is a hard error to fix and takes a lot of things to get around. It was about three hours of debugging and fixing my permissions. Some tutorials setting this up actually can mess things up such as setting the users in the sudo group really makes it hard to define the user directly in: visudo I recommend not adding anything to the sudo group via:
sudo adduser user sudo
This was just my set up so you may need to add a user to sudo but I prefer giving ALL permissions to my users in visudo with:
visudo
user ALL = NOPASSWD:
Hope this someone get around this! it was a dang hard error to fix with a lot happening and was mostly my user errors when configuring capistrano. Good luck! Keep calm and code on!;)

`initialize': No such file or directory - getaddrinfo (Errno::ENOENT) when Rails new app

I try to create a rails app in rails 4.00 with ruby ruby-2.0.0-p247. While bundle install processes, it shows an error: initialize: No such file or directory. Below is output of error
run bundle install
/home/gotzila/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:878:in `initialize': No such file or directory - getaddrinfo (Errno::ENOENT)
from /home/gotzila/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:878:in `open'
from /home/gotzila/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:878:in `block in connect'
from /home/gotzila/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
from /home/gotzila/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:877:in `connect'
from /home/gotzila/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:1449:in `begin_transport'
from /home/gotzila/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:1402:in `transport_request'
from /home/gotzila/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/net/http.rb:1376:in `request'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/vendor/net/http/persistent.rb:935:in `request'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/fetcher.rb:202:in `fetch'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/fetcher.rb:242:in `fetch_dependency_remote_specs'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/fetcher.rb:151:in `fetch_remote_specs'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/fetcher.rb:154:in `fetch_remote_specs'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/fetcher.rb:154:in `fetch_remote_specs'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/fetcher.rb:154:in `fetch_remote_specs'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/fetcher.rb:106:in `specs'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:235:in `block in remote_specs'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:235:in `each'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:235:in `remote_specs'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:163:in `fetch_specs'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:67:in `specs'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:192:in `block (2 levels) in index'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:189:in `each'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:189:in `block in index'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/index.rb:9:in `build'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:185:in `index'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:179:in `resolve'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:109:in `resolve_remotely!'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/installer.rb:83:in `run'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/installer.rb:14:in `install'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/cli.rb:247:in `install'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/vendor/thor/task.rb:27:in `run'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/vendor/thor.rb:344:in `dispatch'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/vendor/thor/base.rb:434:in `start'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/bin/bundle:20:in `block in <main>'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/friendly_errors.rb:3:in `with_friendly_errors'
from /home/gotzila/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/bin/bundle:20:in `<main>'
Fetching gem metadata from https://rubygems.org/....Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
What should i do to solve this problem?
I just had a similar issue and after reinstalling rvm (a headache) a couple days later it came back. This time I tried using comments to isolate which gems in my Gemfile were causing the problem. I noticed it was new gems. Then I tried to simply
gem install <problem_gem>
ERROR: Could not find a valid gem 'problem_gem' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - no such name (https://rubygems.org/latest_specs.4.8.gz)
This made me think I wasn't connected to the internet. Once I connected again.
bundle worked!
bundle install
Clean and Reinstall new RVM and then try again..
Follow this link to install new RVM:
https://rvm.io/rvm/install
I faced similar problem and I installed the current stable version rvm 1.21.13 (stable) of RVM to get rid of this. Although my ruby version was 1.9.3 instead of 2.x

Rails App "Permission Denied" error when installing refinerycms

While trying to install refinery, a rails app, I keep getting the following error:
ESL#new-host-2 ~$ refinerycms /Application/MAMP/htdocs/goodwatching
create
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/fileutils.rb:247:in `mkdir': Permission denied - /Application (Errno::EACCES)
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/fileutils.rb:247:in `fu_mkdir'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/fileutils.rb:221:in `block (2 levels) in mkdir_p'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/fileutils.rb:219:in `reverse_each'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/fileutils.rb:219:in `block in mkdir_p'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/fileutils.rb:205:in `each'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/fileutils.rb:205:in `mkdir_p'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/actions/empty_directory.rb:51:in `block in invoke!'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/actions/empty_directory.rb:133:in `call'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/actions/empty_directory.rb:133:in `invoke_with_conflict_check'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/actions/empty_directory.rb:50:in `invoke!'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/actions.rb:95:in `action'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/actions/empty_directory.rb:15:in `empty_directory'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.13/lib/rails/generators/app_base.rb:103:in `create_root'
from (eval):1:in `create_root'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/task.rb:27:in `run'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/invocation.rb:120:in `invoke_task'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `block in invoke_all'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `each'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `map'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/invocation.rb:126:in `invoke_all'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/group.rb:238:in `dispatch'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/thor-0.16.0/lib/thor/base.rb:425:in `start'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/refinerycms-2.0.10/bin/refinerycms:30:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/refinerycms:23:in `load'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/refinerycms:23:in `<main>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
I've seen a couple similar questions but the resolution always seems to be that target directory either doesn't exist or is owned by root. I've checked and my directory exists, is owned by me and has permissions 755.
update
I tried a lot of things so I'm not 100% sure this is relevant, but I updated rvm and then I was able to run refinercyms goodwatching from inside the original /goodwatching directory. But now I'm getting this multiple times when I run it:
NoMethodError: private method `open' called for Gem::Package:Class
An error occured while installing rake (10.0.4), and Bundler cannot continue.
Make sure that `gem install rake -v '10.0.4'` succeeds before bundling.
When I run gem install rake -v '10.0.4' it does succede, but then I get the same error again immediately after.
Try to use sudo
sudo refinerycms /Application/MAMP/htdocs/goodwatching
UPDATE
try to remove Gemfile.lock
then
sudo gem update --system
sudo gem install bundler
sudo bundle install

Resources