How to change working directory in Torch REPL

The title says it all, how can I change the working directory inside the Torch REPL? I tried to use os.execute ('cd some_dir') calls, but this does not work, as shown here.

th> pwd() --prints: / home / user / Code
th> os.execute('cd ..') --prints: true exit 0
th> pwd() - prints: / home / user / Code

where pwd () is a convenience function that calls os.execute ('pwd').

+4
source share
1 answer

Install the lfs package (it may already be installed, if not "luarocks install luafilesystem")

Then

lfs=require 'lfs'
lfs.chdir(newdir)

In addition, in torch REPL you can execute shell commands with the $ prefix. Example:

th> $ls
+8
source

All Articles