[RUBY] No such file or directory @ rb_sysopen-/Users/○○/Gemfile.lock (Errno :: ENOENT) suffered

When I try to hit the rails command

$ rails ○○
Traceback (most recent call last):
        4: from bin/rails:3:in `<main>`
        3: from bin/rails:3:in `load`
        2: from /Users/user/[Project name]/bin/spring:10:in `<top(required)>`
        1: from /Users/user/[Project name]/bin/spring:10:in `read`
/Users/user/[Project name]/bin/spring:10:in `read`: No such file or directory @ rb_sysopen - /Users/user/[Project name]/Gemfile.lock(Errno::ENOENT)

I got an error like this and cried.

Cause

In the rails command, the contents of Gemfile.lock are referenced because the gem version is also included in the confirmation process. However, this time, there is no Gemfile.lock to be referenced, so an error has occurred.

approach

Gemfile.lock keeps track of the version of gemfile and is automatically generated by the bundle install command, so you need to run bundle install.

Immediately execute bundle install on the application directory ↓

$ pwd
/Users/○○/app name

$ bundle install

Then try entering the rails command again. Then, the rails command should be working safely!

Summary

It may be pretty rudimentary, but I've taken a lot of time with this error in the past ... I hope fewer people suffer from the same error!

Recommended Posts

No such file or directory @ rb_sysopen-/Users/○○/Gemfile.lock (Errno :: ENOENT) suffered
No such file or directory @ rb_sysopen --Error like public/user_images/1.jpg
PG :: ConnectionBad: could not connect to server: No such file or directory
When dealing with whenever in Docker No such file or directory --crontab
Attempting to run gnome-terminal inside a Docker container fails (Failed to execute child process “dbus-launch” (No such file or directory))