compiler
compiler copied to clipboard
Permission Denied Error Due to Unset `ELM_HOME` Environment Variable in `Stuff` Module
Description
When running the Elm compiler without the ELM_HOME environment variable set, it defaults to using the the location of elm im assuming for storing data. In certain environments, the process may lack the necessary permissions to write to this directory, resulting in a Permission Denied error.
This issue stems from the getElmHome function within the Stuff module in the Elm compiler source code. Below is the relevant snippet from the Stuff module:
getElmHome :: IO FilePath
getElmHome =
do maybeCustomHome <- Env.lookupEnv "ELM_HOME"
case maybeCustomHome of
Just customHome -> return customHome
Nothing -> Dir.getAppUserDataDirectory "elm"
In the absence of the ELM_HOME environment variable, getElmHome defaults to using AppUserDataDirectory.
Steps to Reproduce
- Ensure the
ELM_HOMEenvironment variable is not set. - Run the Elm compiler command in an environment where the
AppUserDataDirectoryis not writable by the process. - Observe the
Permission Deniederror.
Thanks for reporting this! To set expectations:
- Issues are reviewed in batches, so it can take some time to get a response.
- Ask questions in a community forum. You will get an answer quicker that way!
- If you experience something similar, open a new issue. We like duplicates.
Finally, please be patient with the core team. They are trying their best with limited resources.
Is this a request for a better error message in this case?
What is an example of an environment where the process lacks permission?
defaults to using the the location of elm
Maybe this is more a problem of the environment. The name getAppUserDataDirectory implies a location that is writable by the current user. If it is giving the location of the elm executable then that's a problem - I wouldn't expect the executable location to be writable in most distros.
Sorry that was my Interpretation of the getAppUserDataDirectory. Im not sure where exactly it was trying to write to. This came up when trying to automate some things with elm make. We were calling elm make from another program process. It all worked locally but then we ran into the createDirectory permissionDenied error when deploying it on fly.io. I think there should be a nicer error message handled by elm. #2042 references a similar issue