Azure Devops Pipeline Matlab Command Bugs between R2019B and R2017B

0

I have a working Azure CI pipeline doing building code gen operations with Matlab 2019. The Matlab project is written for Matlab 2017B. it also builds/work locally with Matlab 2017b or 2019b.

ENV:

It's a self-hosted windows 10 computer connected to Azure Pipelines with multiple version of Matlab. Matlab 2017B is a node-locked license. Matlab2019B is a floating license.

ACTION:

I changed the Matlab version used by the script to 2017B and ran my script to match production server specification.

steps:
  - powershell: Write-Host '##vso[task.prependpath]C:\Program Files\MATLAB\R2017B\bin'  
  - task: RunMATLABCommand@0
    inputs:
      command: myscript

EXPECTED:

It to run without issues. Or, have 1-2 compatibility issues in the script, that I can debug as I go along.

RESULT:

It can't even set Matlab path when it inits. (Which is step 1 of opening matlab, not even part of my script ), hence it has access to no standard Matlab function, and everything breaks..

C:\WINDOWS\system32\cmd.exe /D /S /C "C:\agentS\_work\_tasks\RunMATLABCommand_28fdff80-51b4-4b6e-83e1-cfcf3f3b25a6\0.2.6\bin\run_matlab_command.bat "cd('C:\agentS\_work\_temp'); command_1ae12f20_c2aa_4b55_9c6c_6da1d64c4a30""
C:\Program Files\MATLAB\R2017b\toolbox\local\pathdef.m: Cannot open file: permission denied.
[Warning: MATLAB did not appear to successfully set the search path. To recover for this session of MATLAB,
type "restoredefaultpath;matlabrc". To find out how to avoid this warning the next time you start MATLAB,
...
Undefined function or variable 'pwd'.

Error in buildSequence (line 1)
addpath(pwd); 

Error in command_1ae12f20_c2aa_4b55_9c6c_6da1d64c4a30 (line 2)
buildSequence
ERROR: MATLAB error (starter line:1202) Exit Status: 0x00000001

INFO:

This are my finding & what I tried.

  1. check acess right to file

This is my acess to the 2 files for matlab 2019, 2017.

-rw-r--r--  1 NARCISS Administrators  39652 Aug 17 13:35 pathdef.m (2017B Matlab)

-rw-r--r--  1 NARCISS Administrators  45073 Sep 14 17:11 pathdef.m (2019B Matlab)
  1. Compare Azure & Local Acess to file

I know from Running this locally from my computer, from a terminal not in admin mode:

cat "C:\Program Files\MATLAB\R2017b\toolbox\local\pathdef.m"
cat "C:\Program Files\MATLAB\R2019b\toolbox\local\pathdef.m"

That both file print to terminal.

And Running this from a Azure Pipeline with a Self-Hosted Windows computer(same computer as local), from a terminal not in admin mode:

cat "C:\Program Files\MATLAB\R2017b\toolbox\local\pathdef.m"
cat "C:\Program Files\MATLAB\R2019b\toolbox\local\pathdef.m"

1st File get access denied, second print as regular.

So this could explain why script run good on 2019, but fail on 2017, because it doesn't have access right to the file?

  1. Try to replicate error on matlab locally

I opened Matlab GUI and matlab CLI, locally and tried said problematic line, without any issue.

addpath(pwd); 
  1. Trying online solution to update pathdef.m

I tried doing these steps, with no change:

  1. https://www.mathworks.com/matlabcentral/answers/102432-why-do-i-receive-a-warning-regarding-missing-pathdef-m-when-starting-matlab-7-14-r2012a

  2. https://www.mathworks.com/help/matlab/matlab_env/when-path-not-successfully-set-at-startup.html

  1. I tried one user suggestions(thx), but I don't understand why ls can print file, and at the same time not have access to it. the file has read permission, and the folder has executable permission?
2020-10-02T14:02:11.6188893Z "-------------------------------------------------------"
2020-10-02T14:02:11.6473143Z ls: C:\Program Files\MATLAB\R2017b\toolbox\local\pathdef.m: Permission denied
2020-10-02T14:02:11.6486563Z 885076267 -rwxr-xr-x 1 AI*****$ Administrators 39330 Oct  1 14:10 C:\Program Files\MATLAB\R2017b\toolbox\local\pathdef.m
2020-10-02T14:02:11.6511012Z "-------------------------------------------------------"
2020-10-02T14:02:11.6702428Z 1671000 -rw-r--r-- 1 AI****$ Administrators 45073 Sep 14 17:11 C:\Program Files\MATLAB\R2019b\toolbox\local\pathdef.m
2020-10-02T14:02:11.6722373Z "-------------------------------------------------------"

QUESTION:

I'm kind of stuck. I don't understand the difference in behavior from local CLI and Azure pipeline CLI? Any Idea on how to fix this bug?

matlab
azure-devops
continuous-integration
command-line-interface
azure-pipelines
asked on Stack Overflow Oct 1, 2020 by Weltgeist • edited Oct 2, 2020 by Weltgeist

2 Answers

1

1st File get access denied, second print as regular.

Access local file in the azure devops pipeline via self-hosted agent, It accesses the file via service account instead of Personal account, so you can run the cmd locally from your computer, and get error in the azure devops pipeline.

You need to check the permissions of the service account in the file C:\Program Files\MATLAB\R2017b\toolbox\local\pathdef.m and then try it again.

Update1

You can check the permission of the service account in the file C:\Program Files\MATLAB\R2019b\toolbox\local\pathdef.m and configure the same permission in the C:\Program Files\MATLAB\R2017b\toolbox\local\pathdef.m.

According to the link you shared, it seems that you need r+x permission instead of r

Update2

We can change the agent service account to your owner account.

Steps: Open service on the agent machine and search the agent service account, check the pic below, just change the account name and password to yours, then It will use this account to perform the operation.

enter image description here

answered on Stack Overflow Oct 2, 2020 by Vito Liu • edited Oct 7, 2020 by Vito Liu
0

Well, I found a fix, after installing a second version of MATLAB2017B with another floating license(instead of a node locked license). I have all access rights when running it on Azure pipelines.

cat "C:\Program Files\MATLAB\R2017b\toolbox\local\pathdef.m"
cat "C:\Program Files\MATLAB\R2017b2\toolbox\local\pathdef.m"
cat "C:\Program Files\MATLAB\R2019b\toolbox\local\pathdef.m"

1st one is still access denied. But the 2 others works. R2017B and R2019B. Hence, my MATLAB project open & build as it did with the MATLAB 2019b release.

I'm not sure if it was a acess issue or a licensing issue, see ref below. but it works. ^^. Anyone is free to chyme in, for my general knowledge.

Ref: https://unix.stackexchange.com/questions/411376/ls-is-giving-a-permission-denied-error-even-though-it-worked https://www.unix.com/unix-for-dummies-questions-and-answers/41487-got-basic-doubt-cat-file-permissions.html https://desk.zoho.com/portal/simlabsoftware/en/kb/articles/what-it-is-the-difference-between-standalone-and-floating-license#:~:text=Floating%20license%3A,the%20number%20of%20concurrent%20users. http://kb.mit.edu/confluence/pages/viewpage.action?pageId=4273647

answered on Stack Overflow Oct 2, 2020 by Weltgeist

User contributions licensed under CC BY-SA 3.0