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

Permission Denied Error Due to Unset ELM_HOME Environment Variable in Stuff Module #2315

Open
blackeuler opened this issue Oct 30, 2023 · 4 comments

Comments

@blackeuler
Copy link

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

  1. Ensure the ELM_HOME environment variable is not set.
  2. Run the Elm compiler command in an environment where the AppUserDataDirectory is not writable by the process.
  3. Observe the Permission Denied error.
@github-actions
Copy link

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.

@lydell
Copy link
Contributor

lydell commented Oct 30, 2023

Is this a request for a better error message in this case?

What is an example of an environment where the process lacks permission?

@bburdette
Copy link

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.

@blackeuler
Copy link
Author

blackeuler commented Oct 30, 2023

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

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

3 participants