Skip to content
This repository has been archived by the owner on Sep 26, 2020. It is now read-only.

new file command returns "Access to the path ... is denied" on windows #3

Closed
tabakerov opened this issue Nov 10, 2016 · 3 comments
Closed
Labels

Comments

@tabakerov
Copy link

Expected Behavior

New file should be created and added reference to project

Current Behavior

file created and "Access to the path ... is denied" error returned

Steps to Reproduce (for bugs)

forge new project --name BlogWeb --dir BlogDir --template suave
forge new file --name server --project BlogDir --template fs
and output:

Forge should be run from solution/repository root. Please ensure you don't run it from folder containing other solutions

Do You want to continue? [Y/n]
Y
Unhandled error:
Access to the path 'C:\Users\d.tabakerov\FS\Blog\BlogDir' is denied.```

## Your Environment
Windows 10
@andredublin
Copy link
Contributor

I'm able to reproduce this error. Tried running cmd in administrator mode but still get the same error as described.

@jindraivanek
Copy link
Contributor

I did some digging on this. It looks like new file works only when runned inside project subdirectory. In more detail, Forge now does:

  • copy template file into current directory with new name
  • open project - it assumes fsproj path is in --project parameter (this is where OP example throw exception)
  • add new file to project

What I think new file --project <projectName> should do:

  • find subdirectory "projectName" with .fsproj in it
  • copy new file into that directory
  • add file into fsproj

If agreed, I can do this.

@Krzysztof-Cieslak
Copy link
Member

I've added few integration tests to document current new file behavior. https://github.com/fsharp-editing/Forge/blob/master/tests/Forge.IntegrationTests/NewFileTests.fs

Essentially you need to pass relative path to file location, and relative path to fsproj. However project parameter is optional, if it's not provided we will try to find right project file. It should work well enough in most use cases.

Giving relative paths (relative to repository root, so directory where Forge should be run) is behavior we use for all other commands (add\remove file, project references etc) so wouldn't want to change it.

Also I've released fixed which will handle giving "wrong" project name (printing out warning + trying to find project file automatically), so this error shouldn't occur any more.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

4 participants