rocketeer icon indicating copy to clipboard operation
rocketeer copied to clipboard

Errors running migrations

Open barryvdh opened this issue 9 years ago • 11 comments

Since I upgrade to 2.x I can't run migrations anymore. I've just published new configs and filled them. Migrations fail but that isn't mentioned in the output, only in the logs. It also gives some errors about npm/bower, I don't know why because I haven't configured anything like that.. (I am on the latest dev-develop 36e46f60c1e767bf0912a96564ef499452c1e6f8)

Generating autoload files
which: no npm in (/usr/local/bin:/bin:/usr/bin)
$ cd /home/mysite/domains/mydomain.com/application/production/releases/20141114091957
$ which: no npm in (/usr/local/bin:/bin:/usr/bin) install
bash: -c: line 0: syntax error near unexpected token `('
bash: -c: line 0: `cd /home/mysite/domains/mydomain.com/application/production/releases/20141114091957 && which: no npm in (/usr/local/bin:/bin:/usr/bin) install'
which: no bower in (/usr/local/bin:/bin:/usr/bin)
$ cd /home/mysite/domains/mydomain.com/application/production/releases/20141114091957
$ which: no bower in (/usr/local/bin:/bin:/usr/bin) install
bash: -c: line 0: syntax error near unexpected token `('
bash: -c: line 0: `cd /home/mysite/domains/mydomain.com/application/production/releases/20141114091957 && which: no bower in (/usr/local/bin:/bin:/usr/bin) install'
$ cd /home/mysite/domains/mydomain.com/application/production/releases/20141114091957
$ chmod -R 777 /home/mysite/domains/mydomain.com/application/production/releases/20141114091957/app/storage
$ chmod -R g+s /home/mysite/domains/mydomain.com/application/production/releases/20141114091957/app/storage

$ cd /home/mysite/domains/mydomain.com/application/production/releases/20141114091957
$ chmod -R 777 /home/mysite/domains/mydomain.com/application/production/releases/20141114091957/public
$ chmod -R g+s /home/mysite/domains/mydomain.com/application/production/releases/20141114091957/public

which: unrecognized option '--env=production'
which: no artisan in (/usr/local/bin:/bin:/usr/bin)
/usr/local/bin/php
which: unrecognized option '--env=production'
which: no which: in (/usr/local/bin:/bin:/usr/bin)
which: no unrecognized in (/usr/local/bin:/bin:/usr/bin)
which: no option in (/usr/local/bin:/bin:/usr/bin)
bash: -c: line 1: syntax error near unexpected token `('
bash: -c: line 1: `which: no artisan in (/usr/local/bin:/bin:/usr/bin) --env="production"'
/usr/local/bin/php
$ cd /home/mysite/domains/mydomain.com/application/production/releases/20141114091957
$ /usr/local/bin/php which: unrecognized option '--env=production'
which: no which: in (/usr/local/bin:/bin:/usr/bin)
which: no unrecognized in (/usr/local/bin:/bin:/usr/bin)
which: no option in (/usr/local/bin:/bin:/usr/bin)
bash: -c: line 1: syntax error near unexpected token `('
bash: -c: line 1: `which: no artisan in (/usr/local/bin:/bin:/usr/bin) --env="production"' migrate --env="production"
Could not open input file: which:
bash: -c: line 1: syntax error near unexpected token `('
bash: -c: line 1: `which: no which: in (/usr/local/bin:/bin:/usr/bin)'
$ rm -rf /home/mysite/domains/mydomain.com/application/production/releases/20141114091957/app/storage/logs

barryvdh avatar Nov 14 '14 08:11 barryvdh

Pushed a related fix, can you try again? Should get a clearer output

Anahkiasen avatar Nov 14 '14 15:11 Anahkiasen

Ehh I checked without open migrations, but it doesn't really seem correct..

Generating autoload files
bash: -c: line 1: unexpected EOF while looking for matching ``'
bash: -c: line 2: syntax error: unexpected end of file
$ cd /home/mysite/domains/mydomain.com/application/dev/releases/20141114162840
$ bash: -c: line 1: unexpected EOF while looking for matching ``'
bash: -c: line 2: syntax error: unexpected end of file install
bash: -c: line 0: unexpected EOF while looking for matching `''
bash: -c: line 2: syntax error: unexpected end of file
bash: -c: line 1: unexpected EOF while looking for matching ``'
bash: -c: line 2: syntax error: unexpected end of file
$ cd /home/mysite/domains/mydomain.com/application/dev/releases/20141114162840
$ bash: -c: line 1: unexpected EOF while looking for matching ``'
bash: -c: line 2: syntax error: unexpected end of file install
bash: -c: line 0: unexpected EOF while looking for matching `''
bash: -c: line 2: syntax error: unexpected end of file
$ cd /home/mysite/domains/mydomain.com/application/dev/releases/20141114162840
$ chmod -R 777 /home/mysite/domains/mydomain.com/application/dev/releases/20141114162840/app/storage
$ chmod -R g+s /home/mysite/domains/mydomain.com/application/dev/releases/20141114162840/app/storage

$ cd /home/mysite/domains/mydomain.com/application/dev/releases/20141114162840
$ chmod -R 777 /home/mysite/domains/mydomain.com/application/dev/releases/20141114162840/public
$ chmod -R g+s /home/mysite/domains/mydomain.com/application/dev/releases/20141114162840/public

which: unrecognized option '--env=production'
which: no which: in (/usr/local/bin:/bin:/usr/bin)
which: no unrecognized in (/usr/local/bin:/bin:/usr/bin)
which: no option in (/usr/local/bin:/bin:/usr/bin)
bash: -c: line 1: syntax error near unexpected token `('
bash: -c: line 1: `which: no which: in (/usr/local/bin:/bin:/usr/bin)'
which: unrecognized option '--env=dev'
which: no artisan in (/usr/local/bin:/bin:/usr/bin)
which: unrecognized option '--env=dev'
which: no artisan in (/usr/local/bin:/bin:/usr/bin)
which: unrecognized option '--env=dev'
/home/mysite/domains/mydomain.com/application/dev/releases/20141114162840/artisan
/usr/local/bin/php
which: unrecognized option '--env=dev'
which: no which: in (/usr/local/bin:/bin:/usr/bin)
which: no unrecognized in (/usr/local/bin:/bin:/usr/bin)
which: no option in (/usr/local/bin:/bin:/usr/bin)
Laravel Framework version 4.2.11

Usage:
  [options] command [arguments]

Options:
  --help           -h Display this help message.
[.. more artisan output ..]
which: unrecognized option '--env=dev'
which: no artisan in (/usr/local/bin:/bin:/usr/bin)
which: unrecognized option '--env=dev'
which: no artisan in (/usr/local/bin:/bin:/usr/bin)
which: unrecognized option '--env=dev'
/home/mysite/domains/mydomain.com/application/dev/releases/20141114162840/artisan
/usr/local/bin/php
$ cd /home/mysite/domains/mydomain.com/application/dev/releases/20141114162840
$ /usr/local/bin/php which: unrecognized option '--env=dev'
/home/mysite/domains/mydomain.com/application/dev/releases/20141114162840/artisan migrate --env="dev"
Could not open input file: which:
Nothing to migrate.
$ rm -rf /home/mysite/domains/mydomain.com/application/dev/releases/20141114162840/app/storage/logs

barryvdh avatar Nov 14 '14 15:11 barryvdh

If you manually set 'artisan' => 'artisan' in paths.php do you get the same output?

Anahkiasen avatar Nov 14 '14 15:11 Anahkiasen

I already have that.

barryvdh avatar Nov 14 '14 15:11 barryvdh

Well this just gets weirder and weirder. The issue is, your system's response to which isn't the one Rocketeer expects. Usually it's like npm not found but yours says npm not in ($PATH). Since Rocketeer doesn't recognize that as a negative response it tries to use that as path to the requested binary, and that's where things get hella funky.

Anahkiasen avatar Nov 14 '14 18:11 Anahkiasen

This is my response, on two of my servers, both running Centos6

[barryvdh@srv3 ~]$ which npm
/usr/bin/npm
[barryvdh@srv3 ~]$ which smth
/usr/bin/which: no smth in (/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/home/barryvdh/bin)

[projects@dev bootstrap]$ which npm
/usr/bin/npm
[projects@dev bootstrap]$ which smth
/usr/bin/which: no smth in (/home/projects/.rvm/gems/ruby-2.1.0-dev/bin:/home/projects/.rvm/gems/ruby-2.1.0-dev@global/bin:/home/projects/.rvm/rubies/ruby-2.1.0-dev/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/projects/.rvm/bin:/home/projects/.rvm/bin:/home/projects/bin)

barryvdh avatar Nov 19 '14 13:11 barryvdh

What's weird is I added a check for this kind of response and it's still trying to use it https://github.com/rocketeers/rocketeer/blob/develop/src/Rocketeer/Traits/BashModules/Binaries.php#L159

Anahkiasen avatar Nov 19 '14 13:11 Anahkiasen

Not really what is causing it then, maybe unexpected newline or something?

I ran composer update and am using dev-develop e77c9fe

It did seem to run the migrations now, but still has error in the logs:

Generating autoload files
Generating optimized class loader
Compiling common classes
Compiling views
/usr/bin/npm
bash: -c: line 0: unexpected EOF while looking for matching `''
bash: -c: line 2: syntax error: unexpected end of file
$ cd /home/user/domains/mydomain.com/application/releases/20141119171947
$ chmod -R 777 /home/user/domains/mydomain.com/application/releases/20141119171947/app/storage
$ chmod -R g+s /home/user/domains/mydomain.com/application/releases/20141119171947/app/storage

$ cd /home/user/domains/mydomain.com/application/releases/20141119171947
$ chmod -R 777 /home/user/domains/mydomain.com/application/releases/20141119171947/public
$ chmod -R g+s /home/user/domains/mydomain.com/application/releases/20141119171947/public

bash: -c: line 1: syntax error near unexpected token `('
bash: -c: line 1: `bash: -c: line 0: `which which: no artisan in (/usr/bin:/bin:/usr/sbin:/sbin)''
which: no artisan in (/usr/bin:/bin:/usr/sbin:/sbin)
which: no artisan in (/usr/bin:/bin:/usr/sbin:/sbin)
/home/user/domains/mydomain.com/application/releases/20141119171947/artisan
/bin/php
/home/user/domains/mydomain.com/application/releases/20141119171947/artisan
/bin/php
$ cd /home/user/domains/mydomain.com/application/releases/20141119171947
$ /bin/php /home/user/domains/mydomain.com/application/releases/20141119171947/artisan migrate
**************************************
*     Application In Production!     *
**************************************

Nothing to migrate.
$ rm -rf /home/user/domains/mydomain.com/application/releases/20141119171947/app/storage/logs

barryvdh avatar Nov 19 '14 16:11 barryvdh

Can you try again with latest develop, running with -vvv? I made runRaw commands being displayed in debug verbosity (they used to be hidden no matter what). That'll help me better understand what Rocketeer is trying (and failing) to do

Anahkiasen avatar Nov 28 '14 16:11 Anahkiasen

Sure:

[[email protected]] (production) Generating optimized class loader
[[email protected]] (production) Compiling common classes
[[email protected]] (production) Compiling views
$ [ -e "/home/user/domains/mydomain.com/application/staging/current/package.json" ] && echo "true"
production/0/staging    |------ Dependencies/Npm (Installs dependencies with NPM)
$ cd /home/user/domains/mydomain.com/application/staging/releases/20141128180136
$ npm install
[[email protected]] (production) bash: npm: command not found
$ [ -e "/home/user/domains/mydomain.com/application/staging/current/bower.json" ] && echo "true"
production/0/staging    |------ Dependencies/Bower (Installs dependencies with Bower)
$ cd /home/user/domains/mydomain.com/application/staging/releases/20141128180136
$ bower install
[[email protected]] (production) bash: bower: command not found
production/0/staging    |=> Setting permissions for /home/user/domains/mydomain.com/application/staging/releases/20141128180136/app/storage
$ cd /home/user/domains/mydomain.com/application/staging/releases/20141128180136
$ chmod -R 777 /home/user/domains/mydomain.com/application/staging/releases/20141128180136/app/storage
[...]
production/0/staging    |-- Migrate (Migrates and/or seed the database)
production/0/staging    |---- Migrate/Artisan (Migrates your database with Laravel's Artisan CLI)
production/0/staging    |===> Running outstanding migrations
$ cd /home/user/domains/mydomain.com/application/staging/releases/20141128180136
$ /usr/local/bin/php /home/user/domains/mydomain.com/application/staging/releases/20141128180136/artisan
which: unrecognized option '--env=staging' migrate --env="staging"
[[email protected]] (production) Laravel Framework version 4.2.11

Usage:
  [options] command [arguments]

Options:
  --help           -h Display this help message.
  --quiet          -q Do not output any message.
  --verbose        -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
  --version        -V Display this application version.
  --ansi              Force ANSI output.
  --no-ansi           Disable ANSI output.
  --no-interaction -n Do not ask any interactive question.
  --env               The environment the command should run under.
[[email protected]] (production) Available commands:
[[email protected]] (production) changes                     Display the framework change list
[[email protected]] (production) clear-compiled              Remove the compiled class file
[..]
[[email protected]] (production)
[[email protected]] (production) view:publish                Publish a package's views to the application
[[email protected]] (production)
[[email protected]] (production) bash: line 1: which:: command not found
$ [ -e "/home/user/domains/mydomain.com/application/staging/shared/app/storage/logs" ] && echo "true"
production/0/staging    |=> Sharing file /home/user/domains/mydomain.com/application/staging/releases/20141128180136/app/storage/logs
$ [ -e "/home/user/domains/mydomain.com/application/staging/shared/app/storage/logs" ] && echo "true"
$ [ -e "/home/user/domains/mydomain.com/application/staging/releases/20141128180136/app/storage/logs" ] && echo "true"
$ [ -L "/home/user/domains/mydomain.com/application/staging/releases/20141128180136/app/storage/logs" ] && echo "true"
$ rm -rf /home/user/domains/mydomain.com/application/staging/releases/20141128180136/app/storage/logs
$ ln -s /home/user/domains/mydomain.com/application/staging/shared/app/storage/logs /home/user/domains/mydomain.com/application/staging/releases/20141128180136/app/storage/logs-temp
$ mv -Tf /home/user/domains/mydomain.com/application/staging/releases/20141128180136/app/storage/logs-temp /home/user/domains/mydomain.com/application/staging/releases/20141128180136/app/storage/logs

(also, not sure why bower/npm run. I don't think I have configured that anywhere..)

barryvdh avatar Nov 28 '14 17:11 barryvdh

Any resolution on this ? I'm having the same problem

hemorej avatar Apr 18 '16 18:04 hemorej