2

In FSI, is it possible to run something like

#I @"%APPDATA%/npm/node_modules/blabla/bin/"

instead of

#I @"C:/Users/username/AppData/Roaming/npm/node_modules/blabla/bin/"

Any other options to make it not sensitive to username?

Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107

1 Answers1

1

Not likely you can use environment variables in #I FSI directives.

However you may make your package installation agnostic of user name by using the trick with __SOURCE_DIRECTORY__ built-in identifier similar to one I've described in this SO answer:

  • create a file anchorfsi.fsx with the single line of code

    #I __SOURCE_DIRECTORY__
    

    and put it into the directory %APPDATA% points to

  • add to the command line starting your FSI the term

    --load:%APPDATA%\anchorfsi.fsx
    

Now you can use relative paths in your #r directives.

Just for illustration I put into directory associated with my user profile a folder testlib containing FSharp.Data.dll. The snip below shows how it gets referenced from FSI using the outlined above technique:

enter image description here

Gene Belitski
  • 10,270
  • 1
  • 34
  • 54