Trouble installing dependencies

I’m new to purescript and have been reading about functional programming for a while, wanted to take a deep into a more strict functional language and given that i mainly work on javascript purescript is a good fit.

I’ve created a demo project to practice and did the initial setup:

npm install -g purescript
npm install -g spago
spago init
spago build

First run it goes fine, it installs dependencies without problem, added the arrays package and all.
Later i wanted to add parcel to raise a dev server and test the compiled js code, since there was no package.json i did:

npm init
npm install -D parcel-bundler

After that i’m unable to run spago build nor install additional dependencies. Console outputs a list of dependencies that were installed previously and any new dependencies and dependencies’ dependencies are throwing errors on git:

[info] Installing "web-storage"
Failed to install dependency "lazy"
Git output:

fatal: destination path '.' already exists and is not an empty directory.

What am i doing wrong?

1 Like

Hello and welcome to PureScript and this community :heart:

From what you write it’s not obvious to me what went wrong either.
Do you get this error with npm install or when doing spago xyz?

Can you maybe post a ls of your folder?

1 Like

I didn’t expect to get a reply so soon so i posted and went to sleep. I don’t have spare time right now since I’m at work but i will reply back a few hours from now with a minimal and reliable way to reproduce my error.

1 Like

take your time - I was just getting up and am almost done with work for today :wink:

1 Like

Small aside, if you’re npm install -D'ing for parcel-bundler in a project, you should do the same for PureScript and Spago so your versions are pinned locally instead of globally where your project can’t control it (or where you may forget to update it).

1 Like

I’m getting the same problem after upgrading to 0.15.4 from the last 0.14 version. (It took this long for the new version to appear in FreeBSDs package manager, so I’d just been pinning the package set to the old version.)

In my case “spago init” appears to work, but when I try “spago build” or anything else that actually downloads packages it does this:

Failed to install dependency "effect"
Git output:

fatal: destination path '.' already exists and is not an empty directory.

Aborting installation..

And it does that for each dependency. The directory never changes after “init” (“.spago” contains an empty directory for each dependency):


I’ve tried obvious stuff like rebooting and un/reinstalling to no effect.
Any ideas?

Does spago build --verbose give any additional hints? What is the content of spago.dhall?

Thanks for taking a look.
The spago.dhall is just the standard for a new project at least as far as I can tell:

{ name = "my-project"
, dependencies = [ "console", "effect", "prelude" ]
, packages = ./packages.dhall
, sources = [ "src/**/*.purs", "test/**/*.purs" ]

and the packages.dhall is similar, just:

let upstream =$

in  upstream

The output of spago build --verbose on the new project is:

[debug] Running `getGlobalCacheDir`
[debug] Transformed config is the same as the read one, not overwriting it
[debug] Ensuring that the package set is frozen
[debug] Getting transitive deps
[debug] Running `fetchPackages`
[debug] Checking if `purs` is up to date
[info] Installing 3 dependencies.
[debug] Running `getMetadata`
[debug] Global cache directory: "/home/ben/.cache/spago"
[info] Searching for packages cache metadata..
[info] Recent packages cache metadata found, using it..
[debug] Fetching package prelude
[debug] Fetching package console
[debug] Fetching package effect
[debug] Directory ".spago/__download-prelude-v6.0.1-a568a00ca464d085/download" does not exist,
[debug] Directory ".spago/__download-effect-v4.0.0-5a369c27149ffa07/download" does not exist, creating...
[debug] Directory ".spago/__download-console-v6.0.0-0a654655004ec749/download" does not exist,
[debug] Running `globallyCache`: PackageName {packageName = "prelude"} v6.0.1
[debug] Running `globallyCache`: PackageName {packageName = "effect"} v4.0.0
[debug] Running `globallyCache`: PackageName {packageName = "console"} v6.0.0
[info] Installing "console"
[info] Installing "effect"
[info] Installing "prelude"
Failed to install dependency "console"
Git output:

fatal: destination path '.' already exists and is not an empty directory.

And then goes on to give the same error a couple of times for each dependency before aborting entirely.
The same problem happens with a bigger project.

hmm - really strange - is spago and git up-to-date?

spago is up to date at 0.20.9 and the git from my package manager was a minor version behind, so I compiled that to get the latest (2.38.0) but the problem still happens exactly the same.

1 Like

So this happens in a new directory after you did spago init + spago build right?

Yes, I just started another new project with the latest git, and “spago init” works fine, nothing odd looking in the output form verbose, then “spago build” stuffs up as above.
Amusingly someone has reported a similar issue at Windows issue with the same problem (possibly) caused by Dropbox temporary files. However nothing like that is installed my machine, which is running of FreeBSD anyway.

Let me try to get a “current” git - I think I saw some security-related updates with git and maybe this bug got introduced with very current git-versions


I’ve tried this under Linux (git 2.37.3 - sorry my Distro does not have the current and as Windows worked I did not bother to build it myself) and under Windows (git version - both worked for me.
So I think it’s not git - maybe some other problem.

Is your project folder symlinked or something like this? What about your temp-folder?

Thanks for checking. No, there are no symlinks in the projects. git 2.37.3 was the version I was initially using, so yes as you say, it doesn’t seem to be that.

Maybe someone has more ideas - the only thing I could think off (similar to the issue with Dropbox) is that sometimes Linux creates lost+found folders and maybe those get created before git clone is invoked? AFAIK those are cloned into temp-folders so it’s probably very hard for you to check if those are empty but maybe you find temp-folders by time and can check if they contain something?

All the temp folders, three of them in the example, one for each dependency, are created and then deleted in the .spago directory. I can see them with in my file manager, briefly appearing and then being deleted. I found them undeleted once (I must have interrupted the build or something) and they all seemed to contain normal build artifacts, as far as I could tell. I no longer have those files as I deleted it to start over when I was checking something else.
I just tried interrupting the build a few times, but I can’t seem to do it when the directories still have files in them.

As far as I could find it should not be a path in your .spago file - it uses this package to query your OS paths - so for Linux it should be /tmp/your-name/...)

If you are interested the code is here:

mkTemp' :: Maybe String -> Aff FilePath
mkTemp' maybeSuffix = do
  -- Get a random string
  (HexString random) <- liftEffect do
    now <-
    sha <- Hash.sha256String $ show now <> fromMaybe "" maybeSuffix
    shaToHex sha
  -- Return the dir, but don't make it - that's the responsibility of the client
  let tempDirPath = Path.concat [ Paths.paths.temp, random ]
  pure tempDirPath

Path.paths should be pointing to a record representing the object paths from the npm-package I linked.

Ok that might be the problem, because I think my file manager is telling me that nothing is happening in /tmp. I will have to look at that again tomorrow, getting a bit late here. Thanks very much, I would not have gotten that far on my own.

Just a minute, as far as I can tell that’s this project Spaghetto written in Purescript, which is not yet in production. We’re still using, and I recompiled Spago which is written in Haskell. Took me a while to figure out how I’d managed to compile code written in Purescript without a working version of Spago. I supppose I should look into the other package management options as a work-around in the meantime.