[Rails] What to do if you accidentally install bundle in the production environment in your local environment

[Rails] Measures taken when I accidentally did bundle install in the production environment in the local environment and got confused

Introduction

When I was developing an API with Rails for hobby app development, I mistakenly bundle installed local and production for the first time in a while. It means that I ran bundle install --path vendor / bundle --without test development locally. .. .. At that time, I was able to revive it (probably), so I summarized it.

What happened

I get a lot of unfamiliar errors and can't do anything like rails s.

Countermeasures

Remove .vendor / bundle

If you execute the above command, you will probably have a bundle directory directly under the application. I'm scared, but please delete it altogether first.

Rewrite Gemfile.lock

If you execute rails s etc. in that state, the error content will change, but the gem you were trying to put in the production environment (for example, the gem required for the database in the production environment such as mysql2) is missing! I get angry. This seems to be a problem caused by the mismatch between the installed Gem and what is written in Gemfile.lock. So, delete all the contents of Gemfile.lock.

Then, from a version control tool such as github, copy and paste the information in Gemfile.lock before doing the wrong bundle install.

the end

I've fixed myself this way! I've done it. .. .. I tend to be impatient, but it was quite good. If you find any mistakes or dangerous acts, please let us know.

Recommended Posts

[Rails] What to do if you accidentally install bundle in the production environment in your local environment
What to do if you can't bundle update and bundle install after installing Ruby 3.0.0 in the Rails tutorial
[Note] What to do if bundle install in Chapter 3 of the rails tutorial is not possible
What to do if you get an error with bundle install by entering gem'bcrypt' in your Gemfile
# What to do if you accidentally do rails db: migrate: drop
What to do if you can't use the rails command
What to do if you install Ubuntu
What to do if the Rails page doesn't appear in Rails tutorial 1.3.2
What to do if Cloud9 is full in the Rails tutorial
What to do if you forget the root password in CentOS7
What to do if you get a "302" error in your controller unit test code in Rails
What to do if you can't install the plugin from the Eclipse marketplace
[Programming beginner] What to do when rails s becomes an error in the local development environment
What to do if the Rails server can't start
What to do if you accidentally create a model
What to do if you get To install the missing version, run `gem install bundler: 2.1.4`
[Rails] I want to reset everything because the data in the local environment is strange! What to do before that
What to do if you can't get the text of an element in Selenium
How to install Docker in the local environment of an existing Rails application [Rails 6 / MySQL 8]
What to do if you can't find your API key after deploying to Rails heroku
What to do if you get a java.io.IOException in GlassFish
What to do if mysql2 gets a bundle install error
What to do if you get the warning "Uniqueness validator will no longer enforce case sensitive comparison in Rails 6.1." in Rails 6.0
What to do if you don't see the test code error message in the terminal console
[Rails Tutorial Chapter 2] What to do when you make a mistake in the column name
[Rails] What to do if you can't get an error message with the errors method
What to do if you get an error in Basic authentication during Rails test code
What to do if you get a gcc error in Docker
What to do if you get a DISPLAY error in gym.render ()
What to do if you get angry with OpenSSL with pyenv install
[Rails] How to reset the database in production environment (Capistrano version)
What to do if you cannot roll back the migration (UnknownMigrationVersionError)
[Rails] What to do if you can't get parameters with form_with
[Rails] Reset the database in the production environment
What to do if you get a "Mysql2 :: Error: Operand should contain 1 column (s)" error in Rails
What to do if you get a groovy warning in Thymeleaf Layout
Add gem'rails-i18n','~> 6.0.0' and what to do if bundle install gives an error
What to do if you get an error during rails db: reset
[Composer] [Laravel] What to do if you cannot install due to insufficient memory
What to do if an error occurs when nokogiri enters when bundle install
What to do if you don't like the code generated by swagger-codegen-cli
What to do if the image posted by refile disappears after setting a 404 error page in Rails
What to do if Operation not permitted is displayed when you execute a command in the terminal
What to do if the server tomcat dies
Rails5.1 + puma SSL connection in local production environment
What to do if you push incorrect information
What to do if you get Could not locate Gemfile or .bundle / directory
What to do if you can't activate the select box created by bootstrap-select
What to do if the changes are not reflected in the jar manifest file
What to do if build from command line fails in Android development environment
What to do if the rails server doesn't run out on AWS cloud9
What to do if ffi installation fails when launching an application in Rails
What to do if you get an "A server is already running." Error when you try to start the rails server
What to do if you get a javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake in the IBM JDK
What to do if you have enabled Use the WSL2 based engine in Docker Desktop with insufficient WSL2 installation
How to translate the error message into Japanese (What to do if you cannot log in for some reason)
What to do if the debug gem installation fails
What to do if rails server can't be stopped
If you want to recreate the instance in cloud9
What to do if password authentication fails in Docker/Postgres
SSL in the local environment of Docker / Rails / puma