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

purs --version raise error , probably installation issue #27

Open
shishini opened this issue Dec 27, 2020 · 11 comments
Open

purs --version raise error , probably installation issue #27

shishini opened this issue Dec 27, 2020 · 11 comments

Comments

@shishini
Copy link

When I run purs --version I get an error

PS C:\dev\lang\purescript\project\purescript-book\exercises\chapter2> purs --version
ResourceUnavailable: C:\Users\ammsel\AppData\Roaming\npm\purs.ps1:10
Line |
  10 |  & "$basedir/node_modules/purescript/purs.bin"   $args
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Program 'purs.bin' failed to run: No application is associated with the specified file for this operation.At C:\Users\ammsel\AppData\Roaming\npm\purs.ps1:10 char:1 + &
     | "$basedir/node_modules/purescript/purs.bin"   $args + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.

This is how I installed purescript

PS C:\dev\lang\purescript\project\purescript-book\exercises\chapter2> npm install -g purescript
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

added 152 packages, and audited 153 packages in 14s

6 packages are looking for funding
  run `npm fund` for details

Note that commands such as spago test and spago repl seem to run fine

PS C:\dev\lang\purescript\project\purescript-book\exercises\chapter2> spago repl
PSCi, version 0.13.8
Type :? for help

>

Also note I am running windows 10

@hdgarrood
Copy link
Collaborator

Installing via npm doesn’t normally create a purs.ps1 file, as far as I’m aware, so that might be what’s causing it to get tripped up. Can you let me know what version of npm you’re using and can you also show us the contents of that file please?

@hdgarrood hdgarrood transferred this issue from purescript/purescript Dec 27, 2020
@garyb
Copy link
Member

garyb commented Dec 27, 2020

I think it might if you're using npm in powershell, similar to the way it creates a batch file when using cmd.

@garyb
Copy link
Member

garyb commented Dec 27, 2020

Here's some more info on this issue actually: https://discourse.purescript.org/t/why-not-purs-exe-instead-of-purs-bin/1737

Seems to be to do with the local configuration.

@shishini
Copy link
Author

shishini commented Dec 27, 2020

I was using powershell version 7.1.0 and npm version 7.3.0

And for the record, it is in my path

PS C:\Users\ammsel> get-command purs

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
ExternalScript  purs.ps1                                                      C:\Users\ammsel\AppData\Roaming\npm\purs.ps1

PS C:\Users\ammsel> ($env:Path).Split(";") | Select-String -pattern "npm"

C:\Users\ammsel\AppData\Roaming\npm

PS C:\Users\ammsel>

@shishini
Copy link
Author

Some more details
So it seems that powershell calls purs.ps1 which does not work
but the old command prompt calls purs.cmd which work

If I explicitly call purs.cmd from command shell it works

PS C:\Users\ammsel> purs.bin --version
purs.bin: The term 'purs.bin' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS C:\Users\ammsel> purs.ps1 --version
ResourceUnavailable: C:\Users\ammsel\AppData\Roaming\npm\purs.ps1:10
Line |
  10 |  & "$basedir/node_modules/purescript/purs.bin"   $args
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Program 'purs.bin' failed to run: No application is associated with the specified file for this operation.At C:\Users\ammsel\AppData\Roaming\npm\purs.ps1:10 char:1 + &
     | "$basedir/node_modules/purescript/purs.bin"   $args + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.

PS C:\Users\ammsel> purs.cmd --version
0.13.8
PS C:\Users\ammsel>

@garyb
Copy link
Member

garyb commented Dec 27, 2020

Does the solution in the linked discourse thread work? This in particular: https://discourse.purescript.org/t/why-not-purs-exe-instead-of-purs-bin/1737/13

@hdgarrood
Copy link
Collaborator

I wonder if we should consider renaming it to purs.exe. As far as I know, Windows is the only OS with hangups about what executables can be called; I don't think having it be called purs.exe will cause any harm on other OSes, apart from potentially people thinking they've been shipped the wrong executable.

@shishini
Copy link
Author

shishini commented Dec 27, 2020

I kinda fixed it
I made a copy of purs.bin renamed it to purs.exe
and edited purs.ps1 to point to purs.exe

and now both purs.cmd and purs.exe work in their respective environments

@shishini
Copy link
Author

I did not try the solution in the discourse forum

@garyb
Copy link
Member

garyb commented Dec 27, 2020

I wonder if we should consider renaming it to purs.exe. As far as I know, Windows is the only OS with hangups about what executables can be called; I don't think having it be called purs.exe will cause any harm on other OSes, apart from potentially people thinking they've been shipped the wrong executable.

Yeah, agreed - just figured we should be 100% sure that this is being caused by the same thing. From what @shishini has done to fix it locally, sounds like it is indeed. Thanks!

@shishini
Copy link
Author

shishini commented Jun 22, 2021

Just a reminder that this issue still exist, and when i updated purescript to version 0.14.2 (from 0.13.8),
i had to redo the manual fix

in C:\Users\<username>\AppData\Roaming\npm\node_modules\purescript
i made a copy of purs.bin and renamed it (the copy) to purs.exe

and i edited C:\Users\<username>\AppData\Roaming\npm\purs.ps1
s/purs.bin/purs.exe/
i replaced purs.bin with purs.exe

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