問題
新しいrailsプロジェクトを作ろうとして、rails new
したら下記のようなエラーが出た。
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /mnt/hgfs/Dev/rails_project/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/ext/bootsnap
/home/n/.rbenv/versions/2.6.5/bin/ruby -I /home/n/.rbenv/versions/2.6.5/lib/ruby/site_ruby/2.6.0 -r ./siteconf20191209-2795-4ulozw.rb extconf.rb
creating Makefile
current directory: /mnt/hgfs/Dev/rails_project/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/ext/bootsnap
make "DESTDIR=" clean
current directory: /mnt/hgfs/Dev/rails_project/vendor/bundle/ruby/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: /mnt/hgfs/Dev/rails_project/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/ext/bootsnap
make "DESTDIR=" install
/usr/bin/install -c -m 0755 bootsnap.so ./.gem.20191209-2795-1foym7j/bootsnap
No such file or directory @ rb_file_s_rename - (./.gem.20191209-2795-1foym7j/bootsnap,
/mnt/hgfs/Dev/rails_project/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/bootsnap-1.4.5/bootsnap)
Gem files will remain installed in /mnt/hgfs/Dev/rails_project/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5 for inspection.
Results logged to /mnt/hgfs/Dev/rails_project/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/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.
どうやらoutputファイルの書き込みに失敗しているらしい。
環境
- Windows 10 (ホストOS)
- Ubuntu 18 LTS (ゲストOS)
- VMWare Workstation 15
- Rails 6
原因
VMWareの共有フォルダ機能を使用して、ホストOSのフォルダをゲストOSに共有して、この上で開発をしようとしていたのだがこれが良くなかった。
共有フォルダのパーミッションを確認すると、所有権が全てrootになっており、変更ができない。
このために書き込みに失敗したらしい。
/mnt/hgfs/Dev/rail_project $ ls -la
合計 37
drwxrwxrwx 1 root root 4096 12月 9 11:13 .
drwxrwxrwx 1 root root 4096 12月 9 11:10 ..
drwxrwxrwx 1 root root 0 12月 9 11:10 .bundle
drwxrwxrwx 1 root root 4096 12月 9 11:13 .git
-rwxrwxrwx 1 root root 681 12月 9 11:13 .gitignore
-rwxrwxrwx 1 root root 6 12月 9 11:13 .ruby-version
-rwxrwxrwx 1 root root 1962 12月 9 11:13 Gemfile
-rwxrwxrwx 1 root root 3337 12月 9 11:12 Gemfile.lock
-rwxrwxrwx 1 root root 374 12月 9 11:13 README.md
-rwxrwxrwx 1 root root 227 12月 9 11:13 Rakefile
drwxrwxrwx 1 root root 4096 12月 9 11:13 app
drwxrwxrwx 1 root root 0 12月 9 11:13 bin
drwxrwxrwx 1 root root 4096 12月 9 11:13 config
-rwxrwxrwx 1 root root 130 12月 9 11:13 config.ru
drwxrwxrwx 1 root root 0 12月 9 11:13 db
drwxrwxrwx 1 root root 0 12月 9 11:13 lib
drwxrwxrwx 1 root root 0 12月 9 11:13 log
-rwxrwxrwx 1 root root 222 12月 9 11:13 package.json
drwxrwxrwx 1 root root 4096 12月 9 11:13 public
drwxrwxrwx 1 root root 0 12月 9 11:13 storage
drwxrwxrwx 1 root root 4096 12月 9 11:13 test
drwxrwxrwx 1 root root 0 12月 9 11:13 tmp
drwxrwxrwx 1 root root 0 12月 9 11:13 vendor
解決
共有フォルダ機能を使うのを止めて、ゲストOS上のディレクトリをsambaでホストOSと共有することにしました。
なおゲストOSとホストOSでsambaを使うためには、VMWareのネットワークアダプタの設定をブリッジ接続にする必要があります。