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

Indicate current shell when misconfigured #12483

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

johnyaku
Copy link

@johnyaku johnyaku commented Mar 14, 2023

Description

On HPC systems, the shell used by the job scheduler may not always be the same as that used in interactive sessions. On our HPC, for example, the job scheduler uses csh while interactive sessions start in bash. This confuses users who may have configured, say, ~/.bashrc to initialise conda but may not be aware that the job scheduler uses a different shell by default. These errors can be difficult to debug.

This PR includes the path to the current shell (taken from the $SHELL environment variable) in the error message. Hopefully this will make it easier to spot the fact that the current shell is not the expected shell, and to adjust the job submission flags accordingly.

This PR uses os.popen(). Not sure if this is best practice, but the spirit of the PR is to make these errors easier to debug.

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

Don't think this change is big enough to warrant any of the above.

@johnyaku johnyaku requested a review from a team as a code owner March 14, 2023 08:50
@conda-bot
Copy link
Contributor

We require contributors to sign our Contributor License Agreement and we don't have one on file for @johnyaku.

In order for us to review and merge your code, please e-sign the Contributor License Agreement PDF. We then need to manually verify your signature. We will ping the bot to refresh the PR status when we have confirmed your signature.

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label May 4, 2023
Copy link
Contributor

@travishathaway travishathaway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @johnyaku,

Thank you for submitting this pull request. I have a couple recommendations for improvement that I would like you to check out.

On top of those, another thing you should address is how this will appear for users on Windows. The process of determining the active running shell is a bit different; therefore, I don't think it's important to include. But, I would rather not have these users see empty parenthesis (e.g. ()).

# Perhaps this link would be appropriate? https://docs.conda.io/projects/conda/en/latest/commands/init.html
# Remind users what shell they are currently using.
# Can be different in job schedulers versus interactive sessions, for example
shell = os.popen('echo $SHELL').read().rstrip()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
shell = os.popen('echo $SHELL').read().rstrip()
shell = os.getenv("SHELL")

No need to open a sub process here. Was there a special reason you were doing that?

Comment on lines +301 to +303
# Perhaps this link would be appropriate? https://docs.conda.io/projects/conda/en/latest/commands/init.html
# Remind users what shell they are currently using.
# Can be different in job schedulers versus interactive sessions, for example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Perhaps this link would be appropriate? https://docs.conda.io/projects/conda/en/latest/commands/init.html
# Remind users what shell they are currently using.
# Can be different in job schedulers versus interactive sessions, for example

It's not necessary to include these extra pieces of documentation. I believe it's pretty straightforward what's going on here.

@travishathaway
Copy link
Contributor

@johnyaku,

I have also updated this branch with the latest changes from main, so you will have to perform the following command to get everything working correctly locally for you:

git pull

@travishathaway travishathaway added the source::community catch-all for issues filed by community members label May 4, 2023
@kenodegard
Copy link
Contributor

Unfortunately the $SHELL environment variable isn't a good indicator of what shell conda was invoked from (see https://stackoverflow.com/questions/55597797/detect-whether-current-shell-is-powershell-in-python/55598796#55598796)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA source::community catch-all for issues filed by community members
Projects
Status: 🏗️ In Progress
Development

Successfully merging this pull request may close these issues.

None yet

4 participants