question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Python editor: current working directory behavior is unexpected

See original GitHub issue

Create the following setup:

  • the file browser lists no files
  • create a python script script1.py that produces a file ./file1.txt
  • run script1.py in the editor. ./file1.txt is created in the same directory
  • create a subdirectory dir2
  • in dir2 create a python script script2.py that produces a file ./file2.txt
  • run script2.py in the editor. ./file2.txt is created in the parent directory

I do realize that when one runs python dir2/script2.py in a terminal window, cwd is .. However, in JL I expected cwd to be the directory where the Python script is located, since a drill down in the file browser should be semantically equivalent to a cd dir2. The script name in the editor also lists script2.py not dir2/script2.py, which seems to imply that cwd is the location of the script, not the base directory in the file browser.

Related issue: https://github.com/elyra-ai/elyra/issues/1045

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
karlaspuldarocommented, Nov 9, 2020

@kevin-bates Makes sense, I can take a look at that.

0reactions
lresendecommented, Nov 9, 2020

Reassigning to try to get this to the 1.4 release

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue 22834: Unexpected FileNotFoundError when current ...
getcwd() raises FileNotFoundError when CWD is no longer valid and that is in a fundamental part of importlib that isn't worrying about non- ......
Read more >
Run Python file in Terminal with error "& was unexpected at ...
I was not able to reproduce the problem with the following steps: change my default terminal to "cmd.exe"; right-click in the .py file's...
Read more >
os.chdir() caused unexpected behaviour with python ...
I'm new to multi-threading in Python. In my code, I called a function which changes its working directory with chdir() as follows.
Read more >
Python Files and os.path - 2021 - BogoToBogo
The current working directory is a property that Python holds in memory at all times. There is always a current working directory, whether...
Read more >
Getting unexpected indent error when executing python script ...
It might be that the code in _init_ has been indented with TAB characters while the code in addlightgroup() has been indented with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found