Repository navigation
Conversation
An unpacked install could not find its own standard library, because nothing told it where it had been unpacked to. Every path the compiler needs is the package root plus something, and the package root came from modular.cfg or from MODULAR_MOJO_MAX_PACKAGE_ROOT and from nowhere else, so it was empty for an install that no installer and no shell profile had been near. The directory above the one holding the executable is the answer, and the executable already knows where it is. That goes in as the last resort in Config::getPath, after the config file, the environment and the runfiles have all had nothing to say, so nothing that works today changes. The import path needed one too. It had no default at all, not even a relative one, which is why the standard library was the first thing to go missing. It is lib/mojo under the package root now, next to the REPL entry point that was already found that way. On Linux and macOS this never came up, because an install arrives through a package manager that writes a config file. On Windows the normal way to get a program is to unpack a zip, and a zip cannot carry a config file naming a path nobody knows yet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #329.
An unpacked install could not find its own standard library:
Nothing had told it where it was. Every path the compiler needs is the package root plus something, and the package root came from
modular.cfgor fromMODULAR_MOJO_MAX_PACKAGE_ROOTand from nowhere else, so it was empty for an install that no installer and no shell profile had been near. The import path was worse off again, with no default at all, not even a relative one, which is why the standard library was the first thing to go missing.The directory above the one holding the executable is the answer and the executable already knows where it is. That goes in as the last resort in
Config::getPath, after the config file, the environment and the runfiles have all had nothing to say, so nothing that works today is affected. The import path getslib/mojounder the package root, next to the REPL entry point that was already found the same way.On Linux and macOS this never came up, because an install arrives through a package manager that writes a config file on the way in. On Windows the normal way to get a program is to unpack a zip, and a zip cannot carry a config file naming a path that nobody knows until the moment it is unpacked.
Verified on a Windows host, with
MODULAR_HOME,MODULAR_MOJO_MAX_PACKAGE_ROOTandMODULAR_MOJO_MAX_IMPORT_PATHall unset:Linux tier 0 was run with this change to check the fallback stays out of the way where a config file already answers.
The empty
argv0handed togetMainExecutableis deliberate and there is a comment about it. It is used only where there is no better source, which on Linux means/procis not mounted and on Windows and macOS means never, and an empty string sends that fallback looking along PATH for a program with no name, which fails quietly. A null pointer would be dereferenced there instead.Part of #319, which is the archive this makes usable.