Rails fails to initialize application -- Permission denied @ rb_file_s_rename [SOLVED]


#1

I’m just getting started and using WSL ubuntu https://www.theodinproject.com/courses/web-development-101/lessons/your-first-rails-application?ref=lnav

I am getting an error and rails new my_first_rails_app fails. Searching for solutions shows that there may be a “suite of permission errors” https://github.com/bundler/bundler/issues/5272#issuecomment-269135449 But some of the things I’ve tried as detailed below are just leading back to a dead end so I’m stumped.

rails new my_first_rails_app while cd’d into the correct folder returns:

...
Fetching bindex 0.8.1
Installing bindex 0.8.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bindex-0.8.1/ext/skiptrace
/home/jared/.rbenv/versions/2.6.4/bin/ruby -I /home/jared/.rbenv/versions/2.6.4/lib/ruby/site_ruby/2.6.0 -r ./siteconf20191027-11636-1xonxzc.rb extconf.rb
creating Makefile

current directory: /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bindex-0.8.1/ext/skiptrace
make "DESTDIR=" clean

current directory: /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bindex-0.8.1/ext/skiptrace
make "DESTDIR="
compiling cruby.c
linking shared-object skiptrace/internal/cruby.so

current directory: /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bindex-0.8.1/ext/skiptrace
make "DESTDIR=" install
/usr/bin/install -c -m 0755 cruby.so ./.gem.20191027-11636-d9f3h/skiptrace/internal

Permission denied @ rb_file_s_rename - (./.gem.20191027-11636-d9f3h/skiptrace,
/home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0-static/bindex-0.8.1/skiptrace)

Gem files will remain installed in /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bindex-0.8.1 for inspection.
Results logged to /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0-static/bindex-0.8.1/gem_make.out

An error occurred while installing bindex (0.8.1), and Bundler cannot continue.
Make sure that `gem install bindex -v '0.8.1' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  web-console was resolved to 3.7.0, which depends on
    bindex
         run  bundle exec spring binstub --all
bundler: command not found: spring
Install missing gem executables with `bundle install`

gem install bindex -v '0.8.1' --source 'https://rubygems.org/' returns:

Building native extensions. This could take a while...
/home/jared/.rbenv/versions/2.6.4/lib/ruby/site_ruby/2.6.0/rubygems/ext/builder.rb:76: warning: Insecure world writable dir /home/jared/.rbenv/versions in PATH, mode 040777
ERROR:  Error installing bindex:
        ERROR: Failed to build gem native extension.

    current directory: /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bindex-0.8.1/ext/skiptrace
/home/jared/.rbenv/versions/2.6.4/bin/ruby -I /home/jared/.rbenv/versions/2.6.4/lib/ruby/site_ruby/2.6.0 -r ./siteconf20191027-11689-ru2kpo.rb extconf.rb
creating Makefile

current directory: /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bindex-0.8.1/ext/skiptrace
make "DESTDIR=" clean

current directory: /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bindex-0.8.1/ext/skiptrace
make "DESTDIR="
compiling cruby.c
linking shared-object skiptrace/internal/cruby.so

current directory: /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bindex-0.8.1/ext/skiptrace
make "DESTDIR=" install
/usr/bin/install -c -m 0755 cruby.so ./.gem.20191027-11689-1vhgbf5/skiptrace/internal

Permission denied @ rb_file_s_rename - (./.gem.20191027-11689-1vhgbf5/skiptrace, /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0-static/bindex-0.8.1/skiptrace)

Gem files will remain installed in /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bindex-0.8.1 for inspection.
Results logged to /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0-static/bindex-0.8.1/gem_make.out

I’ve tried chmod -R o-w ~/.rbenv/versions and this has done something:

...
Fetching bindex 0.8.1
Installing bindex 0.8.1 with native extensions
Fetching msgpack 1.3.1
Installing msgpack 1.3.1 with native extensions
Fetching bootsnap 1.4.5
Installing bootsnap 1.4.5 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/ext/bootsnap
/home/jared/.rbenv/versions/2.6.4/bin/ruby -I /home/jared/.rbenv/versions/2.6.4/lib/ruby/site_ruby/2.6.0 -r ./siteconf20191027-11878-10dxs67.rb extconf.rb
creating Makefile

current directory: /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/ext/bootsnap
make "DESTDIR=" clean

current directory: /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/ext/bootsnap
make "DESTDIR="
compiling bootsnap.c
bootsnap.c: In function ‘get_ruby_platform’:
bootsnap.c:240:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
   struct utsname utsname;
   ^~~~~~
bootsnap.c: In function ‘bs_cache_path’:
bootsnap.c:266:39: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘uint64_t {aka long        unsigned int}’ [-Wformat=]
   sprintf(*cache_path, "%s/%02x/%014llx", cachedir, first_byte, remainder);
                             ~~~~~~^
                             %014lx
bootsnap.c: In function ‘bs_rb_fetch’:
bootsnap.c:307:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
   char * cachedir = RSTRING_PTR(cachedir_v);
   ^~~~
bootsnap.c:653:13: warning: ‘output_data’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 else if (!NIL_P(output_data))             goto succeed; /* fast-path, goal */
         ^
bootsnap.c:624:9: note: ‘output_data’ was declared here
   VALUE output_data;  /* return data, e.g. ruby hash or loaded iseq */
     ^~~~~~~~~~~
bootsnap.c: At top level:
cc1: warning: unrecognized command line option ‘-Wno-self-assign’
cc1: warning: unrecognized command line option ‘-Wno-parentheses-equality’
cc1: warning: unrecognized command line option ‘-Wno-constant-logical-operand’
cc1: warning: unrecognized command line option ‘-Wno-cast-function-type’
linking shared-object bootsnap/bootsnap.so

current directory: /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/ext/bootsnap
make "DESTDIR=" install
/usr/bin/install -c -m 0755 bootsnap.so ./.gem.20191027-11878-grb3zy/bootsnap

Permission denied @ rb_file_s_rename - (./.gem.20191027-11878-grb3zy/bootsnap,
/home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0-static/bootsnap-1.4.5/bootsnap)

Gem files will remain installed in /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5 for inspection.
Results logged to /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0-static/bootsnap-1.4.5/gem_make.out        
An error occurred while installing bootsnap (1.4.5), and Bundler cannot continue.
Make sure that `gem install bootsnap -v '1.4.5' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  bootsnap
     run  bundle exec spring binstub --all
bundler: command not found: spring
Install missing gem executables with `bundle install`

I ran gem install bootsnap -v '1.4.5' --source 'https://rubygems.org/' and it suceeded, then retried and got the same error for byebug instead.

And finally gem install byebug -v '11.0.1' --source 'https://rubygems.org/' returns:

Building native extensions. This could take a while...
/home/jared/.rbenv/versions/2.6.4/lib/ruby/site_ruby/2.6.0/rubygems/ext/builder.rb:76: warning: Insecure world writable dir /home/jared/.rbenv in PATH, mode 040777
ERROR:  Error installing byebug:
        ERROR: Failed to build gem native extension.

    current directory: /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/byebug-11.0.1/ext/byebug
/home/jared/.rbenv/versions/2.6.4/bin/ruby -I /home/jared/.rbenv/versions/2.6.4/lib/ruby/site_ruby/2.6.0 -r ./siteconf20191027-12233-x3dpht.rb extconf.rb
creating Makefile

current directory: /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/byebug-11.0.1/ext/byebug
make "DESTDIR=" clean

current directory: /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/byebug-11.0.1/ext/byebug
make "DESTDIR="
compiling breakpoint.c
compiling byebug.c
compiling context.c
compiling locker.c
compiling threads.c
linking shared-object byebug/byebug.so

current directory: /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/byebug-11.0.1/ext/byebug
make "DESTDIR=" install
/usr/bin/install -c -m 0755 byebug.so ./.gem.20191027-12233-1aeowqk/byebug

Permission denied @ rb_file_s_rename - (./.gem.20191027-12233-1aeowqk/byebug, /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0-static/byebug-11.0.1/byebug)

Gem files will remain installed in /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/byebug-11.0.1 for inspection.
Results logged to /home/jared/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0-static/byebug-11.0.1/gem_make.out

#2

I think the issue was VSCode having a remote connection to the sub system. After disconnecting vscode and retrying the command twice it succeeded.

The first time it returned:

Post-install message from chromedriver-helper:

  +--------------------------------------------------------------------+
  |                                                                    |
  |  NOTICE: chromedriver-helper is deprecated after 2019-03-31.       |
  |                                                                    |
  |  Please update to use the 'webdrivers' gem instead.                |
  |  See https://github.com/flavorjones/chromedriver-helper/issues/83  |
  |                                                                    |
  +--------------------------------------------------------------------+

Post-install message from sass:

Ruby Sass has reached end-of-life and should no longer be used.

* If you use Sass as a command-line tool, we recommend using Dart Sass, the new
  primary implementation: https://sass-lang.com/install

* If you use Sass as a plug-in for a Ruby web framework, we recommend using the
  sassc gem: https://github.com/sass/sassc-ruby#readme

* For more details, please refer to the Sass blog:
  https://sass-lang.com/blog/posts/7828841

         run  bundle exec spring binstub --all
* bin/rake: Spring inserted
* bin/rails: Spring inserted

But nothing further. I retried without removing the old attempt as I might have done with other attempts and it succeeded. The second time it returned:

Bundle complete! 18 Gemfile dependencies, 78 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
         run  bundle exec spring binstub --all
* bin/rake: Spring inserted
* bin/rails: Spring inserted