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

Error importing function definition for BASH_FUNC_module' #68

Closed
johny-mnemonic opened this issue Jun 7, 2016 · 17 comments · Fixed by atom/atom#20393
Closed

Error importing function definition for BASH_FUNC_module' #68

johny-mnemonic opened this issue Jun 7, 2016 · 17 comments · Fixed by atom/atom#20393

Comments

@johny-mnemonic
Copy link

johny-mnemonic commented Jun 7, 2016

Since I updated linter-puppet-lint to 0.6.2, I am getting this nasty error:

Error: /usr/bin/bash: module: line 1: syntax error: unexpected end of file /usr/bin/bash: error importing function definition for BASH_FUNC_module' /usr/bin/bash: scl: line 1: syntax error: unexpected end of file /usr/bin/bash: error importing function definition for BASH_FUNC_scl'
Error: /usr/bin/bash: module: line 1: syntax error: unexpected end of file
/usr/bin/bash: error importing function definition for `BASH_FUNC_module'
/usr/bin/bash: scl: line 1: syntax error: unexpected end of file
/usr/bin/bash: error importing function definition for `BASH_FUNC_scl'
    at ChildProcess.<anonymous> (/home/johny/.atom/packages/linter-puppet-lint/node_modules/atom-linter/node_modules/sb-exec/lib/index.js:36:20)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:818:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

I thought, it was caused by Atom editor update, so I tried at least six different versions, which didn't help. So I thought it's caused by Linter plugin itself, as I was getting same error also for linter-erb, but also to no vain. Than I tried downgrading linter-puppet-lint and with 0.6.1 error went away and everything works.

I am running Atom on Linux Fedora with default shell set to ZSH.

@mschuchard
Copy link
Member

The only differences between 0.6.2 and 0.6.1 were updated dependencies.

@johny-mnemonic
Copy link
Author

I see.
Then it has to be caused by some of it's updated dependencies.

How can I help to find out which one is the culprit?

@mschuchard
Copy link
Member

I don't know how npm does dependency versioning. However, you can check the versions of the dependencies in ~/.atom/packages/linter-puppet-lint/node_modules/*/package.json.

@Arcanemagus
Copy link
Member

Actually it looks like your Bash init script is referencing BASH_FUNC_scl, but can't find a definition for that function. Do you see the message above when launching a new terminal?

(The error is being forwarded on from the shell as it tries to execute puppet-lint.)

@mschuchard
Copy link
Member

Well since he is using zsh there is a chance he does not have bash installed, but I would have thought that would break a lot more than just linter-puppet-lint 0.6.2.

@johny-mnemonic
Copy link
Author

Well, I definitely do have bash installed. I don't use it as default shell, but I do regularly use it to test my scripts, as all my production servers do use bash. I don't see any issue when I switch from zsh to bash. I even tried to run atom from bash to see if zsh could be the cause of my troubles, but it didn't change anything.

I tried to find the string BASH_FUNC_scl in whole /etc and also in my home folder and the only place where I found it was here:

~ » grep -Ril BASH_FUNC_scl .*
.atom/storage/no-atom-lint-env.json.bak

Interesting part of that file:

"BASH_FUNC_module()":"() {  eval `/usr/bin/modulecmd bash $*`\n}","BASH_FUNC_scl()":"() {  local CMD=$1;\n if [ \"$CMD\" = \"load\" -o \"$CMD\" = \"unload\" ]; then\n eval \"module $@\";\n else\n /usr/bin/scl \"$@\";\n fi\n}"

Regarding the dependencies, the difference is as follows.
0.6.1 depends on:

atom-linter 3.4.1
-> "dependencies":
    "xregexp": "^2.0.0",
    "tmp": "latest"
atom-package-deps 2.1.3

0.6.2 depends on:

atom-linter 4.0.7
-> "dependencies":
    "named-js-regexp": "^1.3.1",
    "sb-exec": "^1.0.4",
    "sb-promisify": "^1.0.0",
    "tmp": "~0.0.28"
atom-package-deps 3.0.9
-> dependencies": 
    "atom-package-path": "^1.0.2"

As you can see it is pretty big difference. I would bet on that 'sb-exec' package if I had to shoot blindly.

@snahelou
Copy link

snahelou commented Jun 8, 2016

Hello

Same problem for me on a fresh install (fedora22).

I just install Atom (using rpm) and language-puppet/linter-puppet-lint. (0.6.3)

Regards

@snahelou
Copy link

snahelou commented Jun 8, 2016

A workaround is to remove package scl-utils ... Reboot and it's ok.

More information here: https://bugzilla.redhat.com/show_bug.cgi?format=multiple&id=1185565
Hope it can help you.

@mschuchard
Copy link
Member

To be honest, scl-utils is not something you really ever need on Fedora. It is helpful for RHEL.

@johny-mnemonic
Copy link
Author

Oh well, I can confirm that removing of scl-utils does the magic.

I do have it installed intentionally though, as I was using docker with ruby framework based on RSpec to test some of my stuff.

Since then I moved it to one of the virtual instances in the cloud, so I don't need it right now, but sometimes it could handy to be able to run it locally...

Anyway, thanks to all of you to find the root cause and workaround!

@mschuchard
Copy link
Member

I do have it installed intentionally though, as I was using docker with ruby framework based on RSpec to test some of my stuff.

@johny-mnemonic You can do this without scl-utils.

@johny-mnemonic
Copy link
Author

@mschuchard OK, will check it in case I find the need to have it locally again.

@mschuchard
Copy link
Member

Sounds great.
@snahelou are you good here too?

@snahelou
Copy link

Yes it's ok for me :)

Regards

@mschuchard
Copy link
Member

Great, thanks guys!

@anthonyclarka2
Copy link

I ran into a similar issue which I figured I'd share here in case it's useful to anyone.

Got a similar error message: error importing function definition for `BASH_FUNC_module'

After some digging around, I found the culprit to be the file /usr/share/Modules/init/bash:

module() { eval `/usr/bin/modulecmd bash $*`; }
export -f module

MODULESHOME=/usr/share/Modules
export MODULESHOME

if [ "${LOADEDMODULES:-}" = "" ]; then
  LOADEDMODULES=
  export LOADEDMODULES
fi

if [ "${MODULEPATH:-}" = "" ]; then
  MODULEPATH=`sed -n 's/[   #].*$//; /./H; $ { x; s/^\n//; s/\n/:/g; p; }' ${MODULESHOME}/init/.modulespath`
  export MODULEPATH
fi

if [ ${BASH_VERSINFO:-0} -ge 3 ] && [ -r ${MODULESHOME}/init/bash_completion ]; then
 . ${MODULESHOME}/init/bash_completion
fi

Simply removing that file, logging out then back in and opening Atom again, will fix the error.

This file is part of the RPM "environment-modules" on my system (Fedora-24)

A similar issue is discussed here: https://bugzilla.redhat.com/show_bug.cgi?id=1147043

I hope this helps someone in the future

@tkdchen
Copy link

tkdchen commented Nov 13, 2017

My way without the need of removing environment-modules is to start atom from command line, for example,

cd path/to/project
atom .

I'm using konsole5-16.12.3-1.fc25.x86_64 and environment-modules-3.2.10-17.fc24.x86_64

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
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants