Skip to content

Error running scriptcs when the full path to the file is provided #840

Closed

Description

@ashutoshraina

Doing something like

# ashutoshraina at INAshutosr.local in ~/Projects/Scripts [20:23:51]
$ scriptcs HelloWorld.csx
Hello World

was ok.

However, something like

# ashutoshraina at INAshutosr.local in ~ [20:22:36]
$ scriptcs "/Users/ashutoshraina/Projects/Scripts/HelloWorld.csx" 
Parameter "Users/ashutoshraina/Projects/Scripts/HelloWorld.csx" is not supported!

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at ScriptCs.Argument.ArgumentHandler.Parse (System.String[] args) [0x00000] in <filename unknown>:0 
  at ScriptCs.Program.ParseArguments (System.String[] args) [0x00000] in <filename unknown>:0 
  at ScriptCs.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at ScriptCs.Argument.ArgumentHandler.Parse (System.String[] args) [0x00000] in <filename unknown>:0 
  at ScriptCs.Program.ParseArguments (System.String[] args) [0x00000] in <filename unknown>:0 
  at ScriptCs.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 

was not ok.

I would expect this to work by default.
Note : I am on a mac.

Activity

  1. adamralph commented on Oct 24, 2014

    @adamralph
    Contributor

    @ashutoshraina thanks for reporting

  2. ashutoshraina commented on Feb 24, 2015

    @ashutoshraina
    Author

    I think this is fixed now ..are we ok to close ?

  3. adamralph commented on Feb 24, 2015

    @adamralph
    Contributor

    @ashutoshraina can you reproduce the error using script 0.13.3? If you can't, then I guess it is indeed closed.

  4. ashutoshraina commented on Feb 25, 2015

    @ashutoshraina
    Author

    this works with the -script parameter.
    We can then provide the full path and it picks it up correctly, I checked the usual things like script packs are also loaded correctly.

  5. adamralph commented on Feb 25, 2015

    @adamralph
    Contributor

    @ashutoshraina but it still doesn't work without the script parameter? I.e.

    scriptcs "/Users/ashutoshraina/Projects/Scripts/HelloWorld.csx"

    still throws the error?

  6. ashutoshraina commented on Feb 25, 2015

    @ashutoshraina
    Author
    scriptcs "/Users/ashutoshraina/Projects/Scripts/HelloWorld.csx"
    

    still says that the file could not be found.

    However,

    scriptcs Projects/Scripts/HelloWorld.csx
    

    is fine (notice the lack of quotes).

    Again, this fails.

    scriptcs /Users/ashutoshraina/Projects/scripts/Main.csx
    Parameter "Users/ashutoshraina/Projects/scripts/Main.csx" is not supported!
    

    I assumed the script flag was meant for doing this, but may be this should work as well. Reopening this.

  7. adamralph commented on Feb 25, 2015

    @adamralph
    Contributor

    Thanks, I'm going to mark it as a P3 since there is a workaround, but yes, I think we should fix this if possible.

  8. 5 remaining items

  9. jchannon commented on May 9, 2015

    @jchannon
    Contributor
    DEBUG: Resolving IAppDomainAssemblyResolver
    DEBUG: Registering initialization services
    DEBUG: Registering default: ScriptCs.Contracts.IFileSystem
    DEBUG: Registering default: ScriptCs.Contracts.IAssemblyUtility
    DEBUG: Registering default: ScriptCs.Contracts.IPackageContainer
    DEBUG: Registering default: ScriptCs.Contracts.IPackageAssemblyResolver
    DEBUG: Registering default: ScriptCs.Contracts.IAssemblyResolver
    DEBUG: Registering default: ScriptCs.Contracts.IInstallationProvider
    DEBUG: Registering default: ScriptCs.Contracts.IPackageInstaller
    DEBUG: Registering default: ScriptCs.Hosting.IModuleLoader
    DEBUG: Registering default: ScriptCs.Contracts.IAppDomainAssemblyResolver
    DEBUG: Registering default: ScriptCs.Contracts.IFilePreProcessor
    DEBUG: Mapping Assembly Autofac.Integration.Mef to version:3.0.0.0
    DEBUG: Mapping Assembly Autofac to version:3.3.0.0
    DEBUG: Mapping Assembly Common.Logging to version:2.1.2.0
    DEBUG: Mapping Assembly ICSharpCode.NRefactory.CSharp to version:5.0.0.0
    DEBUG: Mapping Assembly ICSharpCode.NRefactory to version:5.0.0.0
    DEBUG: Mapping Assembly Microsoft.Web.XmlTransform to version:2.1.0.0
    DEBUG: Mapping Assembly Mono.CSharp to version:4.0.0.0
    DEBUG: Mapping Assembly Mono.Cecil to version:0.9.5.0
    DEBUG: Mapping Assembly Newtonsoft.Json to version:6.0.0.0
    DEBUG: Mapping Assembly NuGet.Core to version:2.8.60318.667
    DEBUG: Mapping Assembly PowerArgs to version:2.0.4.0
    DEBUG: Mapping Assembly Roslyn.Compilers.CSharp to version:1.2.0.0
    DEBUG: Mapping Assembly Roslyn.Compilers to version:1.2.0.0
    DEBUG: Mapping Assembly ScriptCs.Contracts to version:0.14.0.0
    DEBUG: Mapping Assembly ScriptCs.Core to version:0.14.0.0
    DEBUG: Mapping Assembly ScriptCs.Engine.Mono to version:0.14.0.0
    DEBUG: Mapping Assembly ScriptCs.Engine.Roslyn to version:0.14.0.0
    DEBUG: Mapping Assembly ScriptCs.Hosting to version:0.14.0.0
    DEBUG: Mapping Assembly scriptcs to version:0.14.0.0
    DEBUG: Resolving IModuleLoader
    DEBUG: Resolving IFileSystem
    DEBUG: Only CSharp module is needed - will skip module lookup
    DEBUG: Initializing module: System.Reflection.MonoAssembly
    DEBUG: Resolving ScriptServices
    DEBUG: Registering runtime services
    DEBUG: Registering default: ScriptCs.Contracts.IFileSystem
    DEBUG: Registering default: ScriptCs.Contracts.IAssemblyUtility
    DEBUG: Registering default: ScriptCs.Contracts.IPackageContainer
    DEBUG: Registering default: ScriptCs.Contracts.IPackageAssemblyResolver
    DEBUG: Registering default: ScriptCs.Contracts.IAssemblyResolver
    DEBUG: Registering default: ScriptCs.Contracts.IScriptHostFactory
    DEBUG: Registering default: ScriptCs.Contracts.IFilePreProcessor
    DEBUG: Registering default: ScriptCs.Contracts.IScriptPackResolver
    DEBUG: Registering default: ScriptCs.Contracts.IInstallationProvider
    DEBUG: Registering default: ScriptCs.Contracts.IPackageInstaller
    DEBUG: Registering default: ScriptCs.ScriptServices
    DEBUG: Registering default: ScriptCs.Contracts.IObjectSerializer
    DEBUG: Registering default: ScriptCs.Contracts.IConsole
    DEBUG: Registering default: ScriptCs.Contracts.IFileSystemMigrator
    DEBUG: Registering default: ScriptCs.Contracts.IScriptLibraryComposer
    DEBUG: Resolving IAssemblyResolver
    Copying directory 'bin' to 'scriptcs_bin'...
    
    Unhandled Exception:
    System.UnauthorizedAccessException: Access to the path "scriptcs_bin" is denied.
      at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00000] in <filename unknown>:0 
      at System.IO.Directory.CreateDirectory (System.String path) [0x00000] in <filename unknown>:0 
      at ScriptCs.FileSystem.CopyDirectory (System.String source, System.String dest, Boolean overwrite) [0x00000] in <filename unknown>:0 
      at ScriptCs.FileSystemMigrator.Migrate () [0x00000] in <filename unknown>:0 
      at ScriptCs.Command.CommandFactory.CreateCommand (ScriptCs.ScriptCsArgs args, System.String[] scriptArgs) [0x00000] in <filename unknown>:0 
      at ScriptCs.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
    [ERROR] FATAL UNHANDLED EXCEPTION: System.UnauthorizedAccessException: Access to the path "scriptcs_bin" is denied.
      at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00000] in <filename unknown>:0 
      at System.IO.Directory.CreateDirectory (System.String path) [0x00000] in <filename unknown>:0 
      at ScriptCs.FileSystem.CopyDirectory (System.String source, System.String dest, Boolean overwrite) [0x00000] in <filename unknown>:0 
      at ScriptCs.FileSystemMigrator.Migrate () [0x00000] in <filename unknown>:0 
      at ScriptCs.Command.CommandFactory.CreateCommand (ScriptCs.ScriptCsArgs args, System.String[] scriptArgs) [0x00000] in <filename unknown>:0 
      at ScriptCs.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
    

    I've tried to pull the source locally and debug but it blows up in Xamarin Studio with: Could not load type 'ScriptCs.Hosting.InitializationServices' from assembly 'ScriptCs.Hosting, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

  10. adamralph commented on May 9, 2015

    @adamralph
    Contributor

    Thanks. I was hoping for an indication of the current directory 😢

    I wonder if the current directory handling has been changed in a later version of atom. I suspect this 'bin' folder that it is finding is in the current directory of the atom process or something. Is it possible to tell atom to switch the current directory to that of the script it is running?

  11. jchannon commented on May 9, 2015

    @jchannon
    Contributor

    Yeah I've been looking to find the bin folder too.

    Not sure about how to tell it which directory to use 😢

  12. jchannon commented on May 9, 2015

    @jchannon
    Contributor

    I just installed this alternative package but although it doesn't fail the script isnt run due to the full path to the script file I suspect.

    I also dont like it as you need to put a shebang at the top of the script file

  13. adamralph commented on May 9, 2015

    @adamralph
    Contributor

    It also makes me wonder if we're handling things properly inside scriptcs.
    @scriptcs/core what's the strategy with the scriptcs filesystem artifacts?
    Should they be treated as relative to the script specified in the command
    line or relative to the current directory? It seems we are doing the latter.

    On 11:20, Sat, 9 May 2015 Jonathan Channon notifications@github.com wrote:

    Yeah I've been looking to find the bin folder too.

    Not sure about how to tell it which directory to use [image: 😢]

    —
    Reply to this email directly or view it on GitHub
    #840 (comment).

  14. jchannon commented on May 9, 2015

    @jchannon
    Contributor

    The odd thing is if I execute scriptcs -script /Users/jonathan/Projects/untitled\ folder/hello.csx from the terminal it executes as expected so I'm not sure what the diff is between that and how Atom Runner executes it

  15. jchannon commented on May 9, 2015

    @jchannon
    Contributor

    I've got it to run inside Atom with this package once I did a PR. The slight quirk with this is that you need to open Atom via terminal rather that UI so it picks up $PATH. Here's my PR https://github.com/ilyapalkin/atom-script/pull/1

  16. ashutoshraina commented on May 9, 2015

    @ashutoshraina
    Author

    From what I know the MAC OSX environment variables are different for apps launched via spotlight and cli...The apps launched from spotlight don't pick up your current path from the profile..

  17. paulbouwer commented on May 9, 2015

    @paulbouwer
    Contributor

    I would think they should be relative to the script. The script/s and file
    system artefacts should be co-located.

    On Saturday, May 9, 2015, Adam Ralph notifications@github.com wrote:

    It also makes me wonder if we're handling things properly inside scriptcs.
    @scriptcs/core what's the strategy with the scriptcs filesystem artifacts?
    Should they be treated as relative to the script specified in the command
    line or relative to the current directory? It seems we are doing the
    latter.

    On 11:20, Sat, 9 May 2015 Jonathan Channon <notifications@github.com
    javascript:_e(%7B%7D,'cvml','notifications@github.com');> wrote:

    Yeah I've been looking to find the bin folder too.

    Not sure about how to tell it which directory to use [image: 😢]

    —
    Reply to this email directly or view it on GitHub
    <#840 (comment)
    .

    —
    Reply to this email directly or view it on GitHub
    #840 (comment).

  18. adamralph commented on May 9, 2015

    @adamralph
    Contributor

    I agree

  19. marking commented on Aug 6, 2017

    @marking

    It's been a while since there was any activity on this, but I took a look at it yesterday (5 Aug 2017) and I believe the genesis of the "Unexpected named argument" exception is a problem in PowerArgs running under mono. I'm going to try upgrading the reference to PowerArgs to something more recent and see if that addresses the issue.

  20. happy15 commented on Dec 13, 2018

    @happy15

    0.17.1 installed with brew still encounter the same problem.

    scriptcs t.csx
    

    is ok, while

    scriptcs /tmp/t.csx
    

    complains "Unexpected named argument: tmp/t.csx"

  21. filipw commented on Dec 13, 2018

    @filipw
    Member

    correct, the fix has not been released yet, but it's been merged

  22. happy15 commented on Dec 13, 2018

    @happy15

    correct, the fix has not been released yet, but it's been merged

    @filipw , good to know.

    any planned date for the release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions