sasjs / vscode-extension

SAS Linting, Syntax Highlighting, and Code Execution from VS Code

Home Page:https://marketplace.visualstudio.com/items?itemName=SASjs.sasjs-for-vscode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

example ~/.sasjsrc for SASjs Server on Windows

jbodart-argenx opened this issue · comments

according to VS Code extension page:

The target 🎯 describes the server on which you intend to run the code. The attributes are added to a file in your home directory - ~/.sasjsrc. More info here).

The following attributes are needed for all server types:

Name. An alias to represent the target.
Server Url. The full URL (including port if needed) of your SAS server.
Server Type. Can be SASVIYA, SAS9 or SASJS.

Could you please provide an example of ~/.sasjsrc file showing how to specify Name (MySASjs), Server Url (http://localhost:5000/) and Server Type (SASJS) for SAS BASE desktop?

Please note that a pre-requisite (without Viya or SAS EBI) is to install SASjs Server - as this provides the REST API against your SAS executable.

Once you have SASjs Server running (ie, you can submit code in Studio and get a log back) then you can configure the VS Code target.

The easiest way to do this is to just click the target icon and follow the prompts (using clientID1 for the client)

Screenshot 2022-09-08 at 15 35 06

Ultimately, your .sasjsrc will look like this (but perhaps with http://localhost:5000 as serverUrl):

image

If you are having issues I'd be happy to jump on a call to assist: https://4gl.uk/book

Ok I was able to create a target, and ended up with the following ~/.sasjsrc file:

{
  "targets": [
    {
      "name": "SAS94",
      "serverUrl": "http://localhost:5000",
      "serverType": "SASJS",
      "appLoc": "/Public/app",
      "buildConfig": {
        "initProgram": "",
        "termProgram": "",
        "buildOutputFileName": "SAS94.sas",
        "buildOutputFolder": "sasjsbuild",
        "buildResultsFolder": "sasjsresults",
        "macroVars": {}
      },
      "jobConfig": {
        "jobFolders": [],
        "initProgram": "",
        "termProgram": "",
        "macroVars": {}
      },
      "serviceConfig": {
        "serviceFolders": [],
        "initProgram": "",
        "termProgram": "",
        "macroVars": {}
      },
      "streamConfig": {
        "streamWebFolder": "",
        "streamWeb": false,
        "webSourcePath": "",
        "streamServiceName": "",
        "assetPaths": []
      },
      "deployConfig": {
        "deployScripts": [],
        "deployServicePack": false
      },
      "testConfig": {
        "initProgram": "",
        "termProgram": "",
        "macroVars": {},
        "testSetUp": "",
        "testTearDown": ""
      }
    }
  ]
}

Looks good but I don't see the authConfig, did you try running anything yet? Does SASjs Server work as expected (can you run code in SASjs Studio)?

I can run code. Do you expect some authConfig when running in desktop mode ?

The only problem seems to be the SASUSER location specified in the ..\sasjs-0.19.0\.env file is not taken into account

SAS_PATH=C:\Program Files\SASHome\SASFoundation\9.4\sas.exe 

SAS_OPTIONS="-SASUSER C:\Users\jbodart\Sasuser-sasjs" 

is the SAS_OPTIONS setting in ..\sasjs-0.19.0\.env file overriden by the environment variable SAS_OPTIONS ?

Great! No you are right, there is no authConfig in desktop mode.

About the SAS_OPTIONS - in fact, all it does is create the environment variable. It does not add it to the launch command.

You can see the launch command in the server log under sasjs_root.

Can you try it without the quote marks?

I can see multiple .log files e.g. 20220908154741.log under ..\sasjs-0.19.0\sasjs_root\logs (witch lines like: ::ffff:127.0.0.1 - - [08/Sep/2022:15:08:50 +0000] "POST /SASjsApi/code/execute HTTP/1.1" 200 7275) and multiple folders under ..\sasjs-0.19.0\sasjs_root\sessions\ containing a file named log.log (looks like SAS log) ...
but I can't file any call to sas.exe

I tried removing the quotes without success, the option is not honored:

SAS_OPTIONS=-CONFIG C:\Users\jbodart\Sasuser-sasjs\sas9.cfg

the fact is, I already have a SAS_OPTIONS environment variable used by BASE SAS.

I tried to launch sasjs server from a batch file that modifies the environment variable SAS_OPTIONS as desired, but when I try to submit code I get messages like
session crashed 20220908162148-40055-1662654108706 Error: Command failed: C:\Program Files\SASHome\SASFoundation\9.4\sas.exe -SYSIN C:\Users\jbodart\tools\sasjs-0.19.0\sasjs_root\sessions\20220908162148-40055-1662654108706\code.sas -LOG C:\Users\jbodart\tools\sasjs-0.19.0\sasjs_root\sessions\20220908162148-40055-1662654108706\log.log -PRINT C:\Users\jbodart\tools\sasjs-0.19.0\sasjs_root\sessions\20220908162148-40055-1662654108706\output.lst -WORK C:\Users\jbodart\tools\sasjs-0.19.0\sasjs_root\sessions\20220908162148-40055-1662654108706 -AUTOEXEC C:\Users\jbodart\tools\sasjs-0.19.0\sasjs_root\sessions\20220908162148-40055-1662654108706\autoexec.sas -nologo -nosplash -icon -nodms -noterminal -nostatuswin -SASINITIALFOLDER C:\Users\jbodart\tools\sasjs-0.19.0\sasjs_root\sessions\20220908162148-40055-1662654108706

Hmm. I wonder if there are some conflicting settings in your config file?

What happens if you try to run that command directly?

C:\Program Files\SASHome\SASFoundation\9.4\sas.exe -SYSIN C:\Users\jbodart\tools\sasjs-0.19.0\sasjs_root\sessions\20220908162148-40055-1662654108706\code.sas -LOG C:\Users\jbodart\tools\sasjs-0.19.0\sasjs_root\sessions\20220908162148-40055-1662654108706\log.log -PRINT C:\Users\jbodart\tools\sasjs-0.19.0\sasjs_root\sessions\20220908162148-40055-1662654108706\output.lst -WORK C:\Users\jbodart\tools\sasjs-0.19.0\sasjs_root\sessions\20220908162148-40055-1662654108706 -nologo -nosplash -icon -nodms -noterminal -nostatuswin -SASINITIALFOLDER C:\Users\jbodart\tools\sasjs-0.19.0\sasjs_root\sessions\20220908162148-40055-1662654108706

Note - the autoexec is removed from that command due to a vagarity in how we launch sessions.

If it would help your use case, we could look to add the config file location as a first class option setting.

From experience though it can cause problems (which I suspect might be the issue here) if the .cfg settings conflict with the command line (or environment var) settings.

The command
"C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" -SYSIN C:\Users\jbodart\tools\sasjs-0.19.0\sasjs_root\sessions\20220908162148-40055-1662654108706\code.sas -LOG C:\Users\jbodart\tools\sasjs-0.19.0\sasjs_root\sessions\20220908162148-40055-1662654108706\log.log -PRINT C:\Users\jbodart\tools\sasjs-0.19.0\sasjs_root\sessions\20220908162148-40055-1662654108706\output.lst -WORK C:\Users\jbodart\tools\sasjs-0.19.0\sasjs_root\sessions\20220908162148-40055-1662654108706 -nologo -nosplash -icon -nodms -noterminal -nostatuswin -SASINITIALFOLDER C:\Users\jbodart\tools\sasjs-0.19.0\sasjs_root\sessions\20220908162148-40055-1662654108706 && echo ok
seems to launch something and to close it within the next second, and writes ok to the terminal.

I ended up starting my base SAS session with a non-default SASUSER setting, and let sasjs start its SAS session using the default SASUSER, that prevented conflicts.

I've created an issue in the sasjs/server repo to support a configurable config file: sasjs/server#278

I'll close this one as it appears to have been figured out, but feel free to continue the conversation if this is not the case.