Skip to content

fix(install): set MATLAB's userpath when nansen_install asks for one - #201

Merged
ehennestad merged 1 commit into
devfrom
install-handle-empty-userpath
Nov 8, 2026
Merged

ehennestad merged 1 commit into
devfrom
install-handle-empty-userpath

Conversation

@ehennestad

Copy link
Copy Markdown
Collaborator

When userpath() is empty and no AddonFolder is given, nansen_install calls nansen.internal.setup.resolveEmptyUserpath. That function asked for a folder and printed "Updated MATLAB's userpath to ...", but its userpath(userPathDirectory) line was commented out, and has been since the file was added in 531831b. nansen.config.addons.getDefaultAddonFolder then threw NANSEN:Addons:EmptyUserpath, so the prompt could not lead to an installation.

The commit that added the file gives no reason for commenting the line out.

Changes:

  • resolveEmptyUserpath keeps the two input prompts and passes the answer to the new nansen.internal.setup.setUserpathFromFolder.
  • setUserpathFromFolder creates <entered>/MATLAB/Nansen after confirmation and calls userpath(<entered>/MATLAB). MATLAB adds that folder to the search path and keeps the value for later sessions. The prompt now says so.
  • The function reads userpath() back before printing success, because userpath(newpath) leaves the value unchanged and only warns when addpath can not add the folder. An empty read-back throws NANSEN:Setup:UserpathNotSet.
  • A relative path throws NANSEN:Setup:UserpathFolderNotAbsolute before any folder is created. userpath(newpath) rejects a relative path in R2024b.
  • input throws MATLAB:services:MissingRequiredCapability under -batch, so in batch mode resolveEmptyUserpath throws NANSEN:Setup:EmptyUserpathInBatchMode, which says to run userpath("<full path of an existing folder>") and then nansen_install again.

tests/+nansen/+unittest/+setup/EmptyUserpathTest.m covers these paths. It generates a stub of userpath on a temporary path entry, so no test changes the saved setting, and the stub requires the folder to exist when it is set, as the real function does.

🤖 Generated with Claude Code

nansen_install asks for a folder when userpath is empty, but the
userpath call in resolveEmptyUserpath was commented out while the
message still reported an update. getDefaultAddonFolder then threw
NANSEN:Addons:EmptyUserpath, so the installation could not continue.

Set the userpath from the entered folder and read it back before
reporting success, since MATLAB only warns when it can not add the
folder to the search path. Reject a relative path before anything is
created. In batch mode, where input throws, stop with an error that
says what to run.

Move everything but the prompts to setUserpathFromFolder so that it
can be tested without keyboard input.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Test Results

654 tests  +9   654 ✅ +9   1m 13s ⏱️ -9s
 52 suites +1     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 33b427f. ± Comparison against base commit deaeee6.

@ehennestad
ehennestad merged commit c33735d into dev Nov 8, 2026
5 checks passed
@ehennestad
ehennestad deleted the install-handle-empty-userpath branch November 8, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant