Install on a server
On your own computer, nvs runs from any folder. On a server, the folders it uses need the
correct permissions. Novis checks some of these permissions. If they are wrong, the server does
not start, or nvs prints a warning.
Set up a server
Section titled “Set up a server”- Put
nvsin a folder, for exampleD:\srv\novis\nvs.exeor/opt/novis/nvs. Put that folder on thePATH. - In the project folder, run
nvs init. - Run
nvs service install <name> -- serve <entry file>. Give the entry file as a full path. The command asks for admin rights itself.
cd D:\srv\shopnvs initnvs service install shop -- serve D:\srv\shop\public\index.nvscd /srv/shopnvs initnvs service install shop -- serve /srv/shop/public/index.nvsThe commands work in any order. nvs init, nvs service install and nvs run all use the same
data folder. The service reads the nvs.toml in the data folder. To use the project file instead,
add --config with its full path after --. Read Run as a service.
You need icacls or chmod only for folders you choose yourself,
and for a folder above one of them.
What nvs init does
Section titled “What nvs init does”nvs init creates the data folder with its subfolders cache, tmp, lsp and logs. Then it
writes the project file nvs.toml into the current folder. It prints one line for each path:
created the data folder `D:\srv\novis\.nvsdata`created the project file `D:\srv\shop\nvs.toml`You can run it again. It then creates nothing and overwrites nothing. It prints kept instead of
created, and the exit status is 0.
nvs init also checks the folder it writes into. nvs serve makes the same check later. If
another account can change the folder, nvs init asks:
Restrict `D:\srv\shop` so only you and administrators can change it? [Y/n]On Linux and macOS, the question says root instead of administrators. An empty answer is yes,
and --yes answers yes without asking. On Windows, the change is two icacls commands. On Linux
and macOS, it is chmod go-w.
Without a terminal, or when you answer no, nvs init prints these commands as help. Then it prints
an error: line, and the exit status is 1. It never changes a folder above the one it writes
into. When the folder belongs to another account, nvs init asks for admin rights and runs again.
Admin rights
Section titled “Admin rights”nvs service install, uninstall, start and stop ask for admin rights. nvs init asks only
when it must change a folder that your account cannot change. A command with --dry-run never
asks. nvs run, nvs serve, nvs test and every other command never ask, because your program
should not run as administrator.
On Windows, the command shows the Windows prompt for admin rights (User Account Control). The output
appears in the same window. On Linux and macOS, the command runs again with sudo in the same
terminal.
In an SSH session, a CI job or a program without a console, no prompt can show. The option
--no-elevate has the same result. The command then prints the command to run as administrator or
as root, and the exit status is 1.
The data folder
Section titled “The data folder”Novis keeps its own files in one folder, the data folder. By default, this is the folder
.nvsdata next to the nvs program. The option --data <folder> uses another folder. Every
command accepts it. A relative path starts at the current folder.
| In the data folder | Contains | The setting that moves it |
|---|---|---|
nvs.toml |
the configuration file nvs reads when the current folder has no nvs.toml |
--config |
cache |
compiled programs | [opcache] file_cache_dir |
tmp |
the folders that Core\IO::createTemporaryDirectory creates |
[io] temp_root |
lsp |
files for the editor | the editor’s nvs.stubs.dir setting |
logs |
nvs.log, the log of a service |
[log] target |
nvs init, nvs run, nvs serve, nvs test, nvs build, nvs check and nvs lsp create the
data folder and its subfolders when they do not exist. Other commands, such as nvs config check, never create
it. When nvs creates the folder, only the account that runs nvs can open it. On Windows,
Administrators and SYSTEM can open it too.
With the data folder, a server needs only one folder of its own:
D:\srv\novis\nvs.exeD:\srv\novis\.nvsdata\nvs.tomlD:\srv\novis\.nvsdata\cache\D:\srv\novis\.nvsdata\logs\/opt/novis/nvs/opt/novis/.nvsdata/nvs.toml/opt/novis/.nvsdata/cache//opt/novis/.nvsdata/logs/Put the binary folder on the PATH. When nvs finds no configuration file, it writes
nvs.toml into the data folder. In this file, every setting is present and commented out. Edit
it there. You do not need --config:
nvs serve /srv/app/index.nvsIf the folder you start nvs in has its own nvs.toml, nvs reads that file. The file in the
data folder is then not read.
When the data folder cannot be used
Section titled “When the data folder cannot be used”If nvs cannot create or use the data folder, it prints one warning and keeps running:
warning: Novis cannot use its data folder `/usr/local/bin/.nvsdata`: ...Programs then run without the compile cache, so they start more slowly. Core\IO::createTemporaryDirectory
throws an error. This happens when nvs is in a folder that your account cannot write to, for
example /usr/local/bin. Pass --data with a folder that only your account can change:
nvs --data /home/ana/.nvsdata run report.nvsnvs test needs a folder for temporary files. Without a usable data folder and without
[io] temp_root, it stops with an error.
Choose the folders yourself
Section titled “Choose the folders yourself”You can also choose each folder yourself. The folders can have any names and be anywhere.
nvs init does not restrict these folders. You set their permissions as
Set the permissions shows.
| Folder | Contains | Who writes to it | Who reads it |
|---|---|---|---|
| binary | nvs (nvs.exe on Windows) |
administrators | every account, so that every account can run nvs |
| config | nvs.toml, and the files it includes |
administrators | the account that runs nvs |
| cache | compiled programs | the account that runs nvs |
the account that runs nvs |
| logs | log files | the account that runs nvs |
you decide |
nvs init writes a configuration file in which every setting is present and commented out.
--config tells nvs where the file is:
nvs --config /opt/novis/config/nvs.toml initnvs --config /opt/novis/config/nvs.toml serve /srv/app/index.nvsnvs init never overwrites a file that already exists. The folder for the file must already
exist. Two settings in the file name the cache
and log folders. Write paths with /, also on Windows:
[opcache]file_cache_dir = "/opt/novis/cache"
[log]target = "file:/opt/novis/logs/nvs.log"What Novis checks
Section titled “What Novis checks”A configuration file can allow a program to read files, open network connections and start other programs. An account that can change this file can give itself all of these rights. The same is true for the cache, because Novis runs the compiled programs it finds there.
So Novis checks who owns a folder and who can write to it. It does not check who can read a file. A file or folder passes the check when both of these are true:
| Windows | Linux and macOS | |
|---|---|---|
| The owner is | the account the server runs as, Administrators, a member of Administrators, or SYSTEM |
the account the server runs as, or root |
| Nobody else can write | Everyone, Authenticated Users, Users, Guests and ANONYMOUS LOGON cannot write to it |
the group and others have no write permission |
A permission for one named account, for example your own, passes the check.
| Command | Checks | If the check fails |
|---|---|---|
nvs serve, at the start and each time a configuration file is saved |
every configuration file, and its folder | the error is E0607. At the start, the server does not start. After a save, the server keeps its current settings |
nvs service install, also with --dry-run |
every --config file, for the account the service runs as |
the error is E0607, and nothing is changed. With --dry-run, the exit status is 1 |
nvs service status |
every --config file, for the account the service runs as |
the error is E0607, and the exit status is 1 |
nvs config check --as <account> |
the configuration files, for the account you name | the error is E0607 |
nvs init |
the folder it writes into | it asks to restrict the folder. Without a terminal, or after the answer no, nothing is written, and the exit status is 1 |
nvs run, nvs serve, nvs test, nvs build, nvs check, nvs lsp |
the data folder. For a folder that --data names, also the folder above it |
one warning. The command runs without the data folder |
| every command that compiles a program | the cache folder, and the folder above it | a warning. The program runs, but it is compiled again every time |
nvs run, nvs check and nvs test do not check the configuration files. nvs config check
without --as does not check the owner. The log folder is not checked.
A service runs as the account that --account names. Without --account, it runs as LocalSystem
on Windows and as root on Linux. A configuration file that does not exist yet passes the
install check, because the installer writes it. When status cannot read a file from your
terminal, it prints a warning, and the exit status stays 0. A file in a private folder is an
example. Use an administrator terminal or sudo to check it.
Check for another account
Section titled “Check for another account”nvs config check --as <account> runs the check for the named account on this machine:
| Windows | Linux and macOS | |
|---|---|---|
<account> is |
an account name, LocalSystem, or NT SERVICE\<service> |
a user name or a uid |
NT SERVICE\<service> works before the service exists. A name that the machine does not know
gives the error E0662.
The command checks the files on this machine as they are now. It does not see the copy that a running server already read. It does not see a read-only mount in a container. It does not see a deploy step that changes an owner later.
The default data folder, .nvsdata next to nvs, is checked alone. The folder above it is the
folder of the nvs program, and Novis does not check that folder. An account that can change it
can already replace nvs itself. So protect the binary folder, as the next section shows.
Set the permissions
Section titled “Set the permissions”These steps are for the folders you choose yourself, and for a folder above one of them.
nvs init restricts the folder it writes into. nvs makes the data folder private when it creates
it. nvs service install --account gives the service account its rights in the data folder. Read
Run as a service.
Novis does not check the binary folder. Protect it yourself: step 2 on Windows, the first two lines on Linux. On Windows, a folder that an administrator created passes the owner check for the service account.
On every drive except the system drive, Windows lets Authenticated Users change every new
folder. So every account can replace nvs.exe and edit nvs.toml, and Novis does not accept the
folder.
Run these commands in a Command Prompt that you started with Run as administrator. Replace
svc-novis with the account that runs nvs.
-
Create the folders:
Terminal window mkdir D:\srv\novis\config D:\srv\novis\cache D:\srv\novis\logs -
Remove the right of
Authenticated Usersto change the binary folder. The other folders get the same permissions.Userscan still read and runnvs.Terminal window icacls D:\srv\novis /inheritance:dicacls D:\srv\novis /remove:g *S-1-5-11 -
Make the configuration private. Only administrators and the accounts you add can read it.
Terminal window icacls D:\srv\novis\config /inheritance:dicacls D:\srv\novis\config /remove:g *S-1-5-32-545 -
Give the account that runs
nvsthe right to readconfig, and to changecacheandlogs:Terminal window icacls D:\srv\novis\config /grant svc-novis:(OI)(CI)RXicacls D:\srv\novis\cache /grant svc-novis:(OI)(CI)Micacls D:\srv\novis\logs /grant svc-novis:(OI)(CI)M -
Check the result.
icacls D:\srv\novismust not showAuthenticated UsersorEveryone.Usersmust show(RX)only.
The commands use the SID of each group, which starts with *. A SID is the same in every
language. A group name is not: German Windows calls Authenticated Users “Authentifizierte
Benutzer”. In PowerShell, put quotes around an argument with parentheses: "svc-novis:(OI)(CI)RX".
An administrator account has administrator rights only in a prompt started with Run as
administrator. In a normal prompt, nvs init can report Access is denied (os error 5).
Replace novis with the account that runs nvs.
sudo install -d -o root -g root -m 0755 /opt/novissudo install -o root -g root -m 0755 nvs /opt/novis/nvssudo install -d -o root -g novis -m 0750 /opt/novis/configsudo install -d -o novis -g novis -m 0755 /opt/novis/cachesudo install -d -o novis -g novis -m 0755 /opt/novis/logsroot owns /opt/novis/config. The group novis can read it and cannot write to it. Other
accounts cannot open it. Give nvs.toml the mode 0640 and the same owner and group.
A mode with write permission for the group or for others fails the check, for example 0775,
0777 or 0664. chmod go-w <path> fixes it.
When the check fails
Section titled “When the check fails”Every error message names a path. Change the permissions of that path, even when it is not
the folder you were working in. For example, if D:\srv\novis\config is correct and
D:\srv\novis is not, the message names D:\srv\novis. The help: line under the message
prints the command to run, with the path filled in.
Run nvs config check --as <account> before a service starts. Use the account the service
runs as. Then you see the failure before the start, and you can fix it first:
nvs config check --as shop| Message | What to do |
|---|---|
... grants write access to ..., ... is group-writable or ... is world-writable |
Remove the write permission from the named path. On Windows, the message prints the SID to use. |
... is owned by ..., which is neither this account ... |
Make the owner the account the server runs as, or an administrator. On Windows, run icacls <path> /setowner *S-1-5-32-544 in a prompt started with Run as administrator. |
Access is denied or Permission denied |
Your own account cannot write there. Use an administrator prompt or sudo. nvs init and nvs service install ask for admin rights themselves. |
warning: [opcache] file_cache_dir ... is not used |
Fix the named path. Until then, programs work and start more slowly. |
warning: Novis cannot use its data folder ... |
Fix the named folder, or pass --data with a folder that only your account can change. Until then, programs run without the compile cache. |
