ApyApyA
@ApyApyA (Umi mi)

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

rails newで正常にファイルが作成できない。

rails new でフォルダの作成を図るもエラーが起きる

【やりたかったこと】
デスクトップ配下のディレクトリでrails new hello_appでhello_appフォルダを作成し、rails sでサーバーをたてる。

【起こったこと】
以下のようなエラーが起き、rails srails -vなどを実行しても同じエラーが起きます。

発生している問題・エラー

 Umi@umimi sample_app % rails new sample_app
 create
      create  README.md
      create  Rakefile
      create  .ruby-version
      create  config.ru
      create  .gitignore
      create  .gitattributes
      create  Gemfile
         run  git init from "."
objc[1630]: Class AMSupportURLConnectionDelegate is implemented in both ?? (0x1f6094188) and ?? (0x113eec2b8). One of the two will be used. Which one is undefined.
objc[1630]: Class AMSupportURLSession is implemented in both ?? (0x1f60941d8) and ?? (0x113eec308). One of the two will be used. Which one is undefined.
Initialized empty Git repository in /Users/Umi/Desktop/ドットインストール専用/ruby練習用/sample_app/.git/
      create  package.json
      create  app
      create  app/assets/config/manifest.js
      create  app/assets/stylesheets/application.css

ーーーーーーーーーー省略ーーーーーーーーーーーーーーーーーーーーー
   
      create  storage/.keep
      create  tmp/storage
      create  tmp/storage/.keep
      remove  config/initializers/cors.rb
      remove  config/initializers/new_framework_defaults_6_1.rb
         run  bundle install
Fetching gem metadata from https://rubygems.org/............
Resolving dependencies...
Using rake 13.0.3
Using concurrent-ruby 1.1.8
Using minitest 5.14.4
Using zeitwerk 2.4.2
Using builder 3.2.4
Using erubi 1.10.0
Using racc 1.5.2
Using crass 1.0.6
Using rack 2.2.3
Using nio4r 2.5.7
Using websocket-extensions 0.1.5
Using marcel 1.0.1
Using mini_mime 1.0.3
Using public_suffix 4.0.6
Using bindex 0.8.1
Using msgpack 1.4.2
Using thor 1.1.0
Using bundler 2.2.17
Using rubyzip 2.3.0
Using tilt 2.0.10
Using semantic_range 3.0.0
Using spring 2.1.1
Using sqlite3 1.4.2
Using turbolinks-source 5.2.0
Using i18n 1.8.10
Using tzinfo 2.0.4
Using nokogiri 1.11.3 (arm64-darwin)
Using rack-test 1.1.0
Using websocket-driver 0.7.3
Using mail 2.7.1
Using addressable 2.7.0
Using bootsnap 1.7.5
Using puma 5.3.1
Using rack-mini-profiler 2.3.2
Using rack-proxy 0.6.5
Using sprockets 4.0.2
Using byebug 11.1.3
Using method_source 1.0.0
Using regexp_parser 2.1.1
Using childprocess 3.0.0
Using activesupport 6.1.3.2
Using loofah 2.9.1
Using xpath 3.2.0
Using turbolinks 5.2.1
Using ffi 1.15.0
Using rb-fsevent 0.11.0
Using rails-dom-testing 2.0.3
Using selenium-webdriver 3.142.7
Using globalid 0.4.2
Using activemodel 6.1.3.2
Using activejob 6.1.3.2
Using webdrivers 4.6.0
Using capybara 3.35.3
Using jbuilder 2.11.2
Using rails-html-sanitizer 1.3.0
Using rb-inotify 0.10.1
Using activerecord 6.1.3.2
Using sassc 2.4.0
Using actionview 6.1.3.2
Using listen 3.5.1
Using actionpack 6.1.3.2
Using actioncable 6.1.3.2
Using activestorage 6.1.3.2
Using actionmailer 6.1.3.2
Using railties 6.1.3.2
Using sprockets-rails 3.2.2
Using actionmailbox 6.1.3.2
Using actiontext 6.1.3.2
Using sassc-rails 2.1.2
Using web-console 4.1.0
Using webpacker 5.3.0
Using rails 6.1.3.2
Using sass-rails 6.0.0
Bundle complete! 17 Gemfile dependencies, 73 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
         run  bundle binstubs bundler
       rails  webpacker:install

<dl>/Users</dl>/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/msgpack-1.4.2/lib/msgpack.rb:8:in `require': dlopen(/Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle, 9): no suitable image found.  Did find: (LoadError)
	/Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle: mach-o, but wrong architecture
	/Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle: mach-o, but wrong architecture - /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/msgpack-1.4.2/lib/msgpack.rb:8:in `<top (required)>'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/store.rb:4:in `require'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/store.rb:4:in `block in <top (required)>'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/explicit_require.rb:44:in `rescue in with_gems'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/explicit_require.rb:40:in `with_gems'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/store.rb:4:in `<top (required)>'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache.rb:61:in `require_relative'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache.rb:61:in `<top (required)>'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap.rb:5:in `require_relative'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap.rb:5:in `<top (required)>'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/setup.rb:2:in `require_relative'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/setup.rb:2:in `<top (required)>'
	from /Users/Umi/Desktop/ドットインストール専用/ruby練習用/sample_app/config/boot.rb:4:in `require'
	from /Users/Umi/Desktop/ドットインストール専用/ruby練習用/sample_app/config/boot.rb:4:in `<top (required)>'
	from /Users/Umi/Desktop/ドットインストール専用/ruby練習用/sample_app/bin/rails:4:in `require_relative'
	from /Users/Umi/Desktop/ドットインストール専用/ruby練習用/sample_app/bin/rails:4:in `<top (required)>'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `load'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `call'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/client.rb:30:in `run'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/bin/spring:49:in `<top (required)>'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `load'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `<top (required)>'
	from <internal:/Users/Umi/.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/Users/Umi/.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /Users/Umi/Desktop/ドットインストール専用/ruby練習用/sample_app/bin/spring:10:in `block in <top (required)>'
	from <internal:kernel>:90:in `tap'
	from /Users/Umi/Desktop/ドットインストール専用/ruby練習用/sample_app/bin/spring:7:in `<top (required)>'
	from bin/rails:2:in `load'
	from bin/rails:2:in `<main>'
/Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/msgpack-1.4.2/lib/msgpack.rb:8:in `require': dlopen(/Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle, 9): no suitable image found.  Did find: (LoadError)
	/Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle: mach-o, but wrong architecture
	/Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle: mach-o, but wrong architecture - /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/msgpack-1.4.2/lib/msgpack.rb:8:in `<top (required)>'
	from /Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/store.rb:4:in `require'
	
ーーーーーーーー省略ーーーーーーーーーーーーーーーーーーーーーーーーーーー


      create  config.ru
      create  .gitignore
      create  .gitattributes
      create  Gemfile
         run  git init from "."
objc[1630]: Class AMSupportURLConnectionDelegate is implemented in both ?? (0x1f6094188) and ?? (0x113eec2b8). One of the two will be used. Which one is undefined.
objc[1630]: Class AMSupportURLSession is implemented in both ?? (0x1f60941d8) and ?? (0x113eec308). One of the two will be used. Which one is undefined.
Initialized empty Git repository in /Users/Umi/Desktop/ドットインストール専用/ruby練習用/sample_app/.git

該当するコマンド

rails new ,rails -vrails s

試してみたこと

一度gem uninstall msgpackしてからgem install msgpackをしてみましたが変わらずでした。

###【補足】
・ホームディレクトリなどではrails -vコマンドは正常に使えます。

・他のディレクトリにある以前つくったrailsプロジェクトは、以前はrails sで正常にサーバーを立ち上げられていましたが、今回のエラーが起きてからそちらでも同じエラーが起きるようになってしまいました。
そちらのディレクトリのパスは/Users/Umi/ruby_project/hello_appとなっています。

#【解決しました】

解決いたしましたので参考にさせていただいた記事、行ったことを書き記します。

↑こちらの記事を参考にさせていただいたところgemを再インストールしプロジェクトを作り直せばうまくかもしれないということがわかる。

次に

↑gemの再インストール方法はこちら記事を参考にさせていただきました。
※なお、私は既存のプロジェクトは消さずに進めているため新たにrails newはしていません。

###【gemの再インストールと+αしたこと】

”gem をクリーンにする。”の記事で紹介されている手順どおり進めていき、

% bundle install

まで特に問題なく成功。もう一度rails sを実行すると以下のようなエラーが発生

/Users/Umi/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/webpacker-5.3.0/lib/webpacker/configuration.rb:96:in `read': No such file or directory @ rb_sysopen - /Users/Umi/Desktop/ドットインストール専用/ruby練習用/sample_app/config/webpacker.yml (Errno::ENOENT)

おそらくwebpackerないんだけど!?って怒られてる、と思われる。
なのでそのまま下記コマンドでwebpackerをインストール。

% rails webpacker:install

________めっちゃ長いので省略_________
├─ uuid@3.4.0
├─ wbuf@1.7.3
├─ webpack-dev-middleware@3.7.3
├─ webpack-dev-server@3.11.2
├─ websocket-driver@0.7.4
├─ websocket-extensions@0.1.4
└─ ws@6.2.1
✨  Done in 4.11s.
Webpacker successfully installed 🎉 🍰```

無事成功。再度rails sを実行

Umi@umimi sample_app % rails s
=> Booting Puma
=> Rails 6.1.3.2 application starting in development
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 5.3.1 (ruby 3.0.0-p0) ("Sweetnighter")
*  Min threads: 5
*  Max threads: 5
*  Environment: development
*          PID: 16735
* Listening on http://127.0.0.1:3000
* Listening on http://[::1]:3000
Use Ctrl-C to stop

ちゃんと動いた!
記事自体初投稿で慣れていませんがどなたかのお役に立てれば幸いです。

1

1Answer

Comments

  1. @ApyApyA

    Questioner

    回答ありがとうございます。自力で解決することができました。

Your answer might help someone💌