spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.3k stars 1.61k forks source link

Spyder ignores current working directory setting #6477

Open jvollme opened 6 years ago

jvollme commented 6 years ago

Problem Description

Terminal always assumes home directory, even though "current working directory" was selected in "Preferences"

What steps will reproduce the problem?

  1. create a subdirectory mkdir test
  2. enter subdirectory cd test
  3. run spyder spyder
  4. create new file
  5. run import os and os.getwcd()

Same result occurs if a template file is already created at desired location:

  1. enter subdirectory cd test
  2. open preexisting template spyder ./template.py
  3. run import os and os.getwcd()

What is the expected output? What do you see instead?

extpected output: Current Working Directory (/home/myhome/test)

actual output: Home directory (/home/myhome)

Package Versions

ccordoba12 commented 6 years ago

Current working directory means that a new IPython console (not terminals) will use the cwd of currently focused console, not that Spyder will use the cwd from the terminal it was started. For that, please use our -w option:

spyder -w . ./template.py

However, that option seems to be failing right now (I thought it was working correctly). We'll take a look a this problem in a future release.

jvollme commented 6 years ago

Thanks, so I simply misunderstood the "working directory" setting. Setting the cwd via the drop-down menu over the terminal will do for now then.

csabella commented 6 years ago

@ccordoba12 I looked at this. It seems that if Project Explorer isn't open, then it will use the path from the CLI option -w. However, an open project will override that and become the working directory.

ccordoba12 commented 6 years ago

Yep, that's right. Do you plan to work on this?

csabella commented 6 years ago

What should the behavior be? -w takes precedence over anything else?

ccordoba12 commented 6 years ago

Hard question... What do you think? @jvollme?