Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error importing function definition for `BASH_FUNC_module' #4437

Open
alanmels opened this issue Jun 12, 2020 · 4 comments
Open

error importing function definition for `BASH_FUNC_module' #4437

alanmels opened this issue Jun 12, 2020 · 4 comments

Comments

@alanmels
Copy link

alanmels commented Jun 12, 2020

I know this issue had been addressed on #2065, however that was for earlier versions of Drush, in particular for Drush 8. Now, when Drupal 9 has been released, which requires PHP 7.3 or higher, and according to the table:

Screen Shot 2020-06-12 at 3 35 54 AM
on https://docs.drush.org/en/master/install, we need to get Drush 10 playing nice with Drupal 9 running on PHP 7.3 and higher.

I've tested Drush 10 on both PHP 7.3 and 7.4 and in both cases got the error. And since the other issue had been already closed for long time, I decided to open a new one.

Describe the bug

The drush status command is giving the following two lines error on top of the output:

sh: module: line 1: syntax error: unexpected end of file
sh: error importing function definition for `BASH_FUNC_module'

The whole output is:

drush st
sh: module: line 1: syntax error: unexpected end of file
sh: error importing function definition for `BASH_FUNC_module'
 Drupal version   : 9.0.0                                                                             
 Site URI         : http://default                                                                    
 DB driver        : mysql                                                                             
 DB hostname      : localhost                                                                         
 DB port          :                                                                                   
 DB username      : dev                                                                               
 DB name          : 15917889342189_test                                                               
 Database         : Connected                                                                         
 Drupal bootstrap : Successful                                                                        
 Default theme    : bartik                                                                            
 Admin theme      : seven                                                                             
 PHP binary       : /opt/remi/php74/root/usr/bin/php                                                  
 PHP config       : /etc/opt/remi/php74/php.ini                                                       
 PHP OS           : Linux                                                                             
 Drush script     : /home/dev/domains/test.dev.domain.com/public_html/vendor/drush/drush/drush     
 Drush version    : 10.2.2                                                                            
 Drush temp       : /tmp                                                                              
 Drush configs    : /home/dev/domains/test.dev.domain.com/public_html/vendor/drush/drush/drush.yml 
 Install profile  : standard                                                                          
 Drupal root      : /home/dev/domains/test.dev.domain.com/public_html/web                          
 Site path        : sites/default                                                                     
 Files, Public    : sites/default/files                                                               
 Files, Temp      : /tmp  

Workaround

You can add disable_functions = pcntl_exec in php.ini to get rid of the error. However, in similar manner with #2065, I believe it should be addressed within the Drush context and without tampering with php.ini configuration file.

Wanted to PR looking at 9e9fa51, however Drush 10 does not have the includes/startup.inc file:

root@dev.domain.com:/home/dev/domains/test.dev.domain.com/www/vendor/drush/drush#
l includes/
total 92
drwxrwxr-x  2 dev dev  4096 Jun 12 09:02 .
drwxrwxr-x 15 dev dev  4096 Jun 12 09:02 ..
-rw-rw-r--  1 dev dev  4658 Jun 12 09:02 backend.inc
-rw-rw-r--  1 dev dev 12613 Jun 12 09:02 batch.inc
-rw-rw-r--  1 dev dev  2701 Jun 12 09:02 bootstrap.inc
-rw-rw-r--  1 dev dev  5030 Jun 12 09:02 cache.inc
-rw-rw-r--  1 dev dev  1213 Jun 12 09:02 drupal.inc
-rw-rw-r--  1 dev dev 15217 Jun 12 09:02 drush.inc
-rw-rw-r--  1 dev dev  1128 Jun 12 09:02 environment.inc
-rw-rw-r--  1 dev dev  6183 Jun 12 09:02 filesystem.inc
-rw-rw-r--  1 dev dev  2250 Jun 12 09:02 legacy.inc
-rw-rw-r--  1 dev dev  1388 Jun 12 09:02 output.inc
-rw-rw-r--  1 dev dev   304 Jun 12 09:02 preflight.inc
-rw-rw-r--  1 dev dev   360 Jun 12 09:02 site_install.inc
root@dev.domain.com:/home/dev/domains/test.dev.domain.com/www/vendor/drush/drush#

System Configuration

Q A
Drush version? 10.2.2
Drupal version? 9.0.0
PHP version 7.3, 7.4
OS? Linux
@weitzman
Copy link
Member

I think you are calling a global drush or something. instead of drush, call vendor/bin/drush. there is no sh in the codebase anymore.

@alanmels
Copy link
Author

Thanks for the update. I'll run some more tests later. However, looking at the output of the drush status above, it seems to be calling /home/dev/domains/test.dev.domain.com/public_html/vendor/drush/drush/drush which comes together with Drupal 9.

@ethanbb
Copy link

ethanbb commented Aug 13, 2020

@weitzman I'm getting this too, and yes I'm calling a global drush with a --root argument (using a remote site alias). I was going to use drush-launcher, but then I saw this page which suggests instead downloading a drush 8.x version and installing it globally, which can then hand off execution to a site-local drush based on --root or the working dir. Is that no longer recommended? If so the docs should be updated.

Edit: I guess in the 9.x version of the docs, it does say to use Drush Launcher instead. Why is 8.x shown by default then?

@Eccenux
Copy link

Eccenux commented Mar 28, 2022

Note that for some reason the bug doesn't appear in PHP8. Don't seem to be related to type of drush script.

In both cases I installed drush via Composer.

Steps:

  1. Composer global install (as in https://getcomposer.org/download/).
  2. Add composer installations to path:
    export PATH="$HOME/.config/composer/vendor/bin:$PATH"
  3. Install drush:
    composer global require drush/drush:8.*
  4. Check
    drush ev 'echo PHP_VERSION."\n"'

Result in PHP7:

sh: module: line 1: błąd składni: nieoczekiwany koniec pliku
sh: błąd importu definicji funkcji dla `BASH_FUNC_module'
7.4.20

Result in PHP8:

8.0.13

Note that both drush executables are from $HOME/.config/composer/vendor/bin.

But when I do this steps for PHP7:

# remove drush v8 and install v7
composer global remove drush/drush
composer global require drush/drush:7.*
# check
drush ev 'echo PHP_VERSION."\n"'

Result in PHP7 is OK:

7.4.20

And for PHP8 drush v7 is not working (array problems).

BTW. The path to composer is wrong in the docs: https://docs.drush.org/en/7.x/install/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants