Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Unexpected end of file sh: error importing function definition after update to v1.12.1 #165

Closed
msfernandes opened this issue Mar 2, 2016 · 19 comments · Fixed by atom/atom#20393
Labels

Comments

@msfernandes
Copy link

Error: sh: module: line 1: syntax error: unexpected end of file
sh: error importing function definition for `BASH_FUNC_module'
sh: scl: line 1: syntax error: unexpected end of file
sh: error importing function definition for `BASH_FUNC_scl'
    at parameters.exit (/home/msfernandes/.atom/packages/linter-flake8/node_modules/atom-linter/lib/helpers.js:47:27)
    at triggerExitCallback (/usr/share/atom/resources/app.asar/src/buffered-process.js:213:47)
    at /usr/share/atom/resources/app.asar/src/buffered-process.js:227:18
    at Socket.<anonymous> (/usr/share/atom/resources/app.asar/src/buffered-process.js:98:18)
    at emitOne (events.js:82:20)
    at Socket.emit (events.js:169:7)
    at Pipe._onclose (net.js:469:12)
@Arcanemagus
Copy link
Member

@steelbrain is this possibly a problem with consistent-env pulling in the bash profile?

@steelbrain
Copy link
Contributor

This is a user misconfiguration, the user has syntax errors in their rc files

@Arcanemagus
Copy link
Member

Closing due to the above comment.

@cnicodeme
Copy link

@steelbrain Could you be more precise please? I have the same error as reported and did not touch the rc files manually.

Which rc file are you talking about, and how can I verify that?

@steelbrain
Copy link
Contributor

@cnicodeme Sure, I was referring to the shell rc files, for example if you use bash it would be ~/.bashrc or ~/.zshrc for zsh. To repro the error you can source ~/path/to/rc/for/your/shell and see if you get any errors.

@cnicodeme
Copy link

@steelbrain Thank you for your reply. I'm using Bash so I tried source ~/.bashrc and it did not yield anything. I suspect the bash rc file is correct then.

Do you want me to past the detailled log error from Atom?

@steelbrain
Copy link
Contributor

Yes please, detailed error logs would be helpful

@cnicodeme
Copy link

@steelbrain Here it is :

Error: sh: module: ligne 1: erreur de syntaxe : fin de fichier prématurée sh: erreur lors de l'import de la définition de fonction pour « BASH_FUNC_module » sh: scl: ligne 1: erreur de syntaxe : fin de fichier prématurée sh: erreur lors de l'import de la définition de fonction pour « BASH_FUNC_scl »
Error: sh: module: ligne 1: erreur de syntaxe : fin de fichier prématurée
sh: erreur lors de l'import de la définition de fonction pour « BASH_FUNC_module »
sh: scl: ligne 1: erreur de syntaxe : fin de fichier prématurée
sh: erreur lors de l'import de la définition de fonction pour « BASH_FUNC_scl »
    at ChildProcess.<anonymous> (/home/cnicodeme/.atom/packages/linter-flake8/node_modules/sb-exec/lib/index.js:56:20)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:852:16)
    at Socket.<anonymous> (internal/child_process.js:323:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:492:12)

I'm sorry the output is in French, I hope it won't stop you. If there is something else you need, feel free to ask :)

@steelbrain
Copy link
Contributor

@cnicodeme while the error is still irrelevant to this package and is a user misconfiguration issue, a quick google search lead to me this solution comment.

@cnicodeme
Copy link

Thank you @steelbrain. The issue was not solved via your linked solution, but the link right after (AtomLinter/linter-puppet-lint#68).

I did a search before ending here (my search was the reason I come up here ;)), and I decided to ask because I didn't find the right solution for me. In retrospect, I may have searched with the wrong keyword ;)

For all others that have the same issue here, and are using Fedora, the solution is simple :

  1. Remove scl-utils : sudo dnf remove scl-utils. Don't worry, it's not useful on Fedora (it's more RHEL related)
  2. Reboot, and you won't have the problem again. This is important, if you don't reboot, nothing will change. (Don't ask me why!)

Thank you for your help @steelbrain :)

@pferreir
Copy link

I'm on Fedora but don't have scl-utils installed. I keep seeing this error message all the time.

@faassen
Copy link

faassen commented Jan 28, 2017

I got this message too, but only on one version Fedora 24 and not the other. I removed scl-utils but it had no effect.

But I realized I had flake8 installed in a user-specific bin directory (linking to a virtualenv), and the machine where it worked was using a newer version., and the failing machine had an older version (3.0.x). Once I upgraded to 3.2.1 the problem went away on the machine where it had previously failed.

@pferreir
Copy link

I can confirm that upgrading flake8 works here. Thanks @faassen !

@Unrud
Copy link

Unrud commented May 17, 2017

is this possibly a problem with consistent-env pulling in the bash profile?

consistent-env is causing this problem. It fails if an environment variable contains line breaks.

The original environment contains

  • BASH_FUNC_scl()
    () {  local CMD=$1;
     if [ "$CMD" = "load" -o "$CMD" = "unload" ]; then
     eval "module $@";
     else
     /usr/bin/scl "$@";
     fi
    }

but consistent-env transform it to

  • BASH_FUNC_scl()
    () {  local CMD=$1;
  • if [ "$CMD"
    "load" -o "$CMD" = "unload" ]; then
    

@steelbrain
Copy link
Contributor

Excellent find @Unrud

Could you please post this info on consistent-env repo?

@fiddybux
Copy link

Just as @cnicodeme suggested, I am on Fedora 26 and did:

sudo dnf remove scl-utils

Rebooted and errors gone.

I had not touched my .bashrc file...brand new install of Fedora!

@macm7
Copy link

macm7 commented Jul 4, 2018

Hey guys i'm having same issue but with drupal any clue what could it be?
I'm doing a drush cr to clear cache and drop me this errors.

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

@j3ffyang
Copy link

j3ffyang commented Aug 2, 2018

@cnicodeme - your solution works for me on Fedora 28. Thanks :-)

@cnicodeme
Copy link

Glad I could help ;)

xdelaruelle added a commit to xdelaruelle/atom that referenced this issue Feb 8, 2020
`getEnvFromShell` function calls `env` command through shell to get all
defined environment variable. However `env` also returns the shell
function defined with their whole code written on multiple lines.

Such shell function definitions were not properly handled by
`getEnvFromShell` which led to the following kind of error messages
(seen for instance when running a terminal package in Atom):

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

With this change `getEnvFromShell` now skips shell function definition
to guarantee only environment variables are recorded and a sane `result`
array is returned.

Fixes atom#20389
Fixes atom#17369
Fixes atom#13451
Fixes blueimp/atom-open-terminal-here#27
Fixes blueimp/atom-open-terminal-here#18
Fixes bus-stop/Termination#101
Fixes bus-stop/terminus#24
Fixes platformio/platformio-atom-ide-terminal#120
Fixes platformio/platformio-atom-ide-terminal#293
Fixes AtomLinter/linter-pylint#243
Fixes AtomLinter/linter-flake8#643
Fixes AtomLinter/linter-flake8#165
Fixes AtomLinter/linter-flake8#422
Fixes AtomLinter/linter-puppet-lint#68
Fixes autocomplete-python/autocomplete-python#347
xdelaruelle added a commit to xdelaruelle/atom that referenced this issue Feb 8, 2020
`getEnvFromShell` function calls `env` command through shell to get all
defined environment variable. However `env` also returns the shell
function defined with their whole code written on multiple lines.

Such shell function definitions were not properly handled by
`getEnvFromShell` which led to the following kind of error messages
(seen for instance when running a terminal package in Atom):

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

With this change `getEnvFromShell` now skips shell function definition
to guarantee only environment variables are recorded and a sane `result`
array is returned.

Fixes atom#20389
Fixes atom#17369
Fixes atom#13451
Fixes blueimp/atom-open-terminal-here#27
Fixes blueimp/atom-open-terminal-here#18
Fixes bus-stop/Termination#101
Fixes bus-stop/terminus#24
Fixes platformio/platformio-atom-ide-terminal#120
Fixes platformio/platformio-atom-ide-terminal#293
Fixes AtomLinter/linter-pylint#243
Fixes AtomLinter/linter-flake8#643
Fixes AtomLinter/linter-flake8#165
Fixes AtomLinter/linter-flake8#422
Fixes AtomLinter/linter-puppet-lint#68
Fixes autocomplete-python/autocomplete-python#347
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants