Incomprehensible (for me) changes not staged for commit

Hi,

after few weeks of inactivity I ran today on my master branch the command ‘git status’, and I got this:

krfg@SATELLITE-L50-A-161:~/workspace/example_app (master)*$ git status On branch master Your branch is up-to-date with ‘origin/master’. Changes not staged for commit: (use “git add/rm …” to update what will be committed) (use “git checkout – …” to discard changes in working directory)

deleted:    bin/bundle
deleted:    bin/rails
deleted:    bin/rake
deleted:    bin/setup
deleted:    bin/spring

no changes added to commit (use “git add” and/or “git commit -a”)

I am wondering why bin/bundle, bin/rails, bin/rake, bin/setup and bin/spring result deleted and what does it mean. I tried to run ‘bundle exec rake db:migrate:status’ and ‘rails -v’ to check if bundle and rails would respond and it seems all right. So what do all these changes not staged for commit mean? Moreover, they refer to a path (bin) which is outside my working tree, so why in the first place git would trace changes to this path?

I am on a Ubuntu 14.04 LTS machine. The only explanation I can guess is that the bin directory might have hosted symbolic links to bundle, rails, rake, setup and spring, and that a system upgrade might have deleted them.

I am using Rails 4.2.2, ruby 2.2.1p85 and rvm. ‘rails server’ does not work anymore. ‘rails console --sandbox’ does not work anymore:

krfg@SATELLITE-L50-A-161:~/ workspace/example_app (master)*$ rails console --sandbox Usage: rails new APP_PATH [options]

Options: -r, [–ruby=PATH] # Path to the Ruby binary of your choice # Default: /home/krfg/.rvm/rubies/ruby-2.2.1/bin/ruby -m, [–template=TEMPLATE] # Path to some application template (can be a filesystem path or URL) [–skip-gemfile], [–no-skip-gemfile] # Don’t create a Gemfile -B, [–skip-bundle], [–no-skip-bundle] # Don’t run bundle install -G, [–skip-git], [–no-skip-git] # Skip .gitignore file [–skip-keeps], [–no-skip-keeps] # Skip source control .keep files -O, [–skip-active-record], [–no-skip-active-record] # Skip Active Record files -S, [–skip-sprockets], [–no-skip-sprockets] # Skip Sprockets files [–skip-spring], [–no-skip-spring] # Don’t install Spring application preloader -d, [–database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc) # Default: sqlite3 -j, [–javascript=JAVASCRIPT] # Preconfigure for selected JavaScript library # Default: jquery -J, [–skip-javascript], [–no-skip-javascript] # Skip JavaScript files [–dev], [–no-dev] # Setup the application with Gemfile pointing to your Rails checkout [–edge], [–no-edge] # Setup the application with Gemfile pointing to Rails repository [–skip-turbolinks], [–no-skip-turbolinks] # Skip turbolinks gem -T, [–skip-test-unit], [–no-skip-test-unit] # Skip Test::Unit files [–rc=RC] # Path to file containing extra configuration options for rails command [–no-rc], [–no-no-rc] # Skip loading of extra configuration options from .railsrc file

Runtime options: -f, [–force] # Overwrite files that already exist -p, [–pretend], [–no-pretend] # Run but do not make any changes -q, [–quiet], [–no-quiet] # Suppress status output -s, [–skip], [–no-skip] # Skip files that already exist

Rails options: -h, [–help], [–no-help] # Show this help message and quit -v, [–version], [–no-version] # Show Rails version number and quit

Description: The ‘rails new’ command creates a new Rails application with a default directory structure and configuration at the path you specify.

You can specify extra command-line arguments to be used every time
'rails new' runs in the .railsrc configuration file in your home directory.

Note that the arguments specified in the .railsrc file don't affect the
defaults values shown above in this help message.

On 8 August 2016 at 13:36, 'krfg' via Ruby on Rails: Talk

Hi,

after few weeks of inactivity I ran today on my master branch the command 'git status', and I got this:

krfg@SATELLITE-L50-A-161:~/workspace/example_app (master)*$ git status On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit:   (use "git add/rm <file>..." to update what will be committed)   (use "git checkout -- <file>..." to discard changes in working directory)

    deleted: bin/bundle     deleted: bin/rails     deleted: bin/rake     deleted: bin/setup     deleted: bin/spring

no changes added to commit (use "git add" and/or "git commit -a")

I am wondering why bin/bundle, bin/rails, bin/rake, bin/setup and bin/spring result deleted and what does it mean. I tried to run 'bundle exec rake db:migrate:status' and 'rails -v' to check if bundle and rails would respond and it seems all right. So what do all these changes not staged for commit mean? Moreover, they refer to a path (bin) which is outside my working tree, so why in the first place git would trace changes to this path?

The are (or were) in your tree. The rails root dir contains a bin directory with those files in it. Somehow they have been deleted. I suggest you do git checkout . (note the dot on the end) which will restore them from the repository. Don't know whether that will fix the problem with rails server etc.

Colin

Restored them with ‘git checkout .’ as you suggested. rails server and rails console were also restored. I have no whatsoever idea why and how they were deleted, and this is not good. I had problems lately with Atom, my text editor, which keeps crashing, and I opened an issue at GitHub, so this may be related to what happened. My application is always in Atom tree view, and sometimes I open some file only for reading its contents, but I stopped working before the issue with Atom arose.

Many many thanks for your help Colin!

On 8 August 2016 at 15:52, 'krfg' via Ruby on Rails: Talk

The are (or were) in your tree. The rails root dir contains a bin directory with those files in it. Somehow they have been deleted. I suggest you do git checkout . (note the dot on the end) which will restore them from the repository. Don't know whether that will fix the problem with rails server etc.

Colin

Restored them with 'git checkout .' as you suggested. rails server and rails console were also restored. I have no whatsoever idea why and how they were deleted, and this is not good.

Have a look in the Rubbish Bin to see if they are there. If they are then almost certainly you accidentally deleted them at some point. Another possibility, and something I have done myself, is accidentally drag the directory off somewhere else from the File Explorer. You could try a search of the whole machine for those files and see if they have accidentally been moved somewhere else. It is of course to recover from exactly this sort of situation that we use something like git :slight_smile:

Colin