How do you change the current directory in GAP? I wrote:
gap> ChangeDirectoryCurrent("Users/anymuanalifah/Documents")
and I received an error. I use Mac OS X if that matters.
How do you change the current directory in GAP? I wrote:
gap> ChangeDirectoryCurrent("Users/anymuanalifah/Documents")
and I received an error. I use Mac OS X if that matters.
Short answer:
The path is incorrect, /
is missing before Users
. Assuming the rest of the path is correct, you need to enter
ChangeDirectoryCurrent("/Users/anymuanalifah/Documents");
Long answer:
This function belongs to the IO package, it is documented at https://www.gap-system.org/Manuals/pkg/io-4.4.6/doc/chap4.html#X81DDD2E87F68E086.
It may be nice to have it in the core system in one of the future GAP releases, but for now, in order to use it the IO package must be compiled and loaded. If GAP is installed as instructed at http://www.gap-system.org/Releases/index.html, then IO will be be compiled as a result of running bin/BuildPackages.sh
script.
IO package is loaded by default in a standard GAP installation, so you do not have load it manually, unless you have a different setup. To load it manually, you have to call LoadPackage("io");
which should return true
if case of success.
Finally, the path in the argument should exist. In your case, it's not clear if it was a typo in the original command, or when you retyped it manually here (otherwise, there would be a space after the gap>
prompt). If the output was indeed
ChangeDirectoryCurrent("Users/anymuanalifah/Documents")
then the error message (which would be most useful to include in the original question) would likely tell the path does not exist - because of the missing /
before Users
): can you try
ChangeDirectoryCurrent("/Users/anymuanalifah/Documents")
and see if it works? Otherwise, the operating system tries to find the directory called Users
in your current directory, and not in the root directory, and that likely fails (for navigating files and directories in Unix, see http://swcarpentry.github.io/shell-novice/02-filedir/index.html from the Software Carpentry shell lesson).
Note that you can customise GAP using gap.ini and gaprc files so that there will be no need to enter this command manually each time you start GAP.
(This is still not the way how I start GAP in the directory I need: I usually open the Terminal, navigate to the directory I need and enter the gap
command which calls /usr/local/bin/gap
which is a symlink that points to the gap-4.9.3/bin/gap.sh
file from my GAP installation)
Finally, I see that this question has been asked on Oct 11, but I got email notification about it only today. For technical questions like this I recommend GAP Forum and GAP Support: see https://www.gap-system.org/Contacts/Forum/forum.html where it would most likely be answered by now. There is also a GAP tag on the Mathematics Q&A site with about 400 questions at the moment, but please read its description here before posting anything there.