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

%cd magic does not work #11

Closed
gaow opened this issue May 8, 2018 · 7 comments
Closed

%cd magic does not work #11

gaow opened this issue May 8, 2018 · 7 comments

Comments

@gaow
Copy link
Member

gaow commented May 8, 2018

Is this the pending PR request will address, or can be fixed without upstream changes?

2018-05-08-11-44-30_scrot

@BoPeng
Copy link
Contributor

BoPeng commented May 8, 2018

%cd does not change the current directory of a running kernel so it needs to be executed before the kernel is started.

I could not find a way to change current directory of a running process.

@BoPeng
Copy link
Contributor

BoPeng commented May 8, 2018

But when I think of this problem now, I think we can define a command for each kernel and execute it silently to change directory with the %cd magic.

@gaow
Copy link
Member Author

gaow commented May 8, 2018

So this is indeed specific to JupyterLab and related to the PR? Because back in SoS notebook:

2018-05-08-12-08-10_scrot

and I've been relying on this feature to keep my notebook out of the dir with messy output data files.

@BoPeng
Copy link
Contributor

BoPeng commented May 8, 2018

No. If you start a subkernel before you use %cd, %cd does not apply to the subkernel.

This should be the same for JLab and Jupyter Notebook.

@BoPeng
Copy link
Contributor

BoPeng commented May 8, 2018

  • sos: os.chdir(os.path.expanduser(to_dir))
  • python2/python3: the same
  • R: setwd(dir)
  • matlab: cd dir
  • node/javascript: process.chdir('/tmp');
  • bash: cd dir
  • SAS: x 'cd <full path>'; (according to here)
  • julia: cd("/")

A potential problem is that dir might be given in a format that is not acceptable to some of the kernels.

@BoPeng
Copy link
Contributor

BoPeng commented May 8, 2018

From Jupyter Notebook, not lab

  1. cd before kernel starts

image

  1. cd after kernel starts

image

BoPeng pushed a commit to vatlab/sos-julia that referenced this issue May 8, 2018
BoPeng pushed a commit to vatlab/sos-bash that referenced this issue May 8, 2018
BoPeng pushed a commit to vatlab/sos-python that referenced this issue May 8, 2018
BoPeng pushed a commit to vatlab/sos-matlab that referenced this issue May 8, 2018
BoPeng pushed a commit to vatlab/sos-javascript that referenced this issue May 8, 2018
BoPeng pushed a commit to vatlab/sos-sas that referenced this issue May 8, 2018
BoPeng pushed a commit to vatlab/sos-notebook that referenced this issue May 8, 2018
@BoPeng
Copy link
Contributor

BoPeng commented May 8, 2018

Fixed.

image

@BoPeng BoPeng closed this as completed May 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants