MATLAB Answers

[ERROR] FOUserAgent - Image not found. Encountered using publish r2018a

187 views (last 30 days)
David Clemens-Sewall
David Clemens-Sewall on 26 Apr 2018
Commented: Roberto Barumerli on 25 Sep 2020 at 11:49
I recently changed from r2016b to r2018a and now the publish function is not displaying plots. When I attempt to publish the following code to pdf I receive the subsequent error and the pdf publishes without the plot.
Code:
% test_publish.m
figure;
plot(1:10);
<<untitled.tif>>
Error
[ERROR] FOUserAgent - Image not found. URI: C:/Users/David Clemens-Sewall/AppData/Local/Temp/test_publish_01.bmp. (See position -1:-1)
[ERROR] FOUserAgent - Image not found. URI: C:/Users/David Clemens-Sewall/AppData/Local/Temp/test_publish_01.bmp. (No context info available)
I'm operating on Windows 10 and unfortunately I had already deleted r2016b so I cannot simply return to using that. By saving the plot and then loading it explicitly I can add it to the pdf. So it seems that publish is capable of loading and displaying the image it's just that matlab is trying to write the plots to a location it cannot access (the directory does exist, but when I go there I do not find the plots). I've looked at changing my temporary directory but unfortunately clear all followed by setenv doesn't seem to change that either (it keeps stubbornly returning to 'C:/Users/David Clemens-Sewall/AppData/Local/Temp/'). So I'm not sure where to go next. Thank you!

  8 Comments

Show 5 older comments
Walter Roberson
Walter Roberson on 4 Jun 2018
You should probably contact Mathworks Support for this. The regular volunteers do not appear to use Publish regularly.
Image Analyst
Image Analyst on 6 Jun 2018
Did you change your original question and code? This code
% test_publish.m
figure;
plot(1:10);
<<untitled.tif>>
that you posted would not cause any problem. It will run (I tried it), though if you call it publish.m, it will override the build-in publish() function, which is never a good idea.
VIVEK RUHELA
VIVEK RUHELA on 27 Feb 2019
I am facing the same problem in Matlab-2018b. With code given in question, I am not getting any image in pdf file. Rest plot is working fine but while publishing, I am getting the same error as reported in the question. Any other suggestions....
Thanks

Sign in to comment.

Answers (6)

Ben Drebing
Ben Drebing on 5 Jun 2018
It looks like this error happens if there is a space in a folder name in the path to your current working folder. So, if you move your code somewhere else so that none of the folders in the path have a space in their name, you should be able to publish.

  4 Comments

Show 1 older comment
Walter Roberson
Walter Roberson on 6 Jun 2018
Historically, some of the Mathworks tools and some of the third-party tools have failed to put quotation marks around names when building command lines to be executed by the shell. For example,
include_dir = fullfile(matlabroot, 'include');
cmd = ['copyfile ' include_dir '\mex.h .]
system(cmd)
Might turn into
copyfile c:\Programs And Executables\MATLAB\R2018a\include\mex.h .
which will fail because copyfile will interpret that as having arguments
c:\Programs
And
Executables\MATLAB\R2018a\include\mex.h
.
More proper code would have been
include_dir = fullfile(matlabroot, 'include');
cmd = sprintf('copyfile "%s\\mex.h" .', include_dir);
system(cmd)
which would turn into
copyfile "c:\Programs And Executables\MATLAB\R2018a\include\mex.h" .
which turns into copyfile arguments
c:\Programs And Executables\MATLAB\R2018a\include\mex.h
.
Simulink used to be quite bad at this. The third-party android tools used to be weak on this as well.
When there is a bug like this, if you just happen to be using a directory and file that contains no spaces, then everything works.
Brad Stiritz
Brad Stiritz on 26 Feb 2020
Hi Ben,
I'm working in R2019b Update 4, and I'm experiencing this same issue. I'm not seeing any embedded spaces on my end-- Maybe I'm not understanding your suggested workarounds--?
Ben>It looks like this error happens if there is a space in a folder name in the path to your current working folder.
>> pwd
ans ='W:\Matlab-work\FATE'
Ben>So, if you move your code somewhere else so that none of the folders in the path have a space in their name, you should be able to publish.
My MLX file is in the following folder--
W:\Matlab-work\FATE\Studies\Ad-Hoc
Here's one of the error messages I got, when I tried to export MLX to PDF--
[ERROR] FOUserAgent - Image not found. URI: file:///C:/Users/brads/AppData/Local/Temp/Exporter9081147262246435610/0B6E7D67.png. (See position 1:6301)
But are you saying that we have to check the entire Matlab path, to ensure there are no spaces in any of the folders? I'm sorry, but this sounds a little onerous, doesn't it..?
Any further clarification appreciated please,
Thanks,
Brad

Sign in to comment.


Cesar Martinez Delgado
Cesar Martinez Delgado on 21 Aug 2018
Edited: Cesar Martinez Delgado on 21 Aug 2018
I have the same problem when I try to publish pdfs or docs. I have tried to change the entire folder to a new one that does not have space in the name. Also, I tried adding to the path the folder that is show in the error. And kind of made the entire track of the function publish to catch the mistake because it. But, it always drops the same error heading to the same path, using the OP sample: C:/Users/ David Clemens-Sewall/AppData/Local/Temp/ Any further assistance on this? Changing the user name would in theroy help, but i do not know if it is gonna mess other applications, which I would avoid to happen. thank you

  0 Comments

Sign in to comment.


Ryan Whitney
Ryan Whitney on 24 Sep 2019
I continue to run into this issue. Sometimes it happens and if I change something in the code (minor, unrelated) or restart Matlab and it will output.
Other times, like RIGHT NOW (very frustrated) there appears to be nothing I can do to export this to PDF. I've had this issue on multiple versions :(.
I'd like to see MathWorks work on fixing this as they are clearly putting work into Livescripts and having the ability to run an analysis and export to PDF is super useful (still some formatting controls to work out, but I'm patient on that).
I'm running 2019b, on MacOS 10.14.6.

  1 Comment

Ryan Whitney
Ryan Whitney on 24 Sep 2019
I've looked in the folder on my laptop where the images are supposed to be and it does not exist. So that explains the error - but I see all the plots in the viewer, but they are not where Matlab wants to look on the file system.

Sign in to comment.


Robert Herring
Robert Herring on 1 Feb 2020
The easiest way to solve this is by changing your user environment variables so that the TMP and TEMP variable have a filepath with no spaces in them. I made a folder on my C drive called 'Temp', then set the environment variables TEMP and TMP for my user to 'C:\Temp'. The following Micrsoft tutorial will help.

  0 Comments

Sign in to comment.


Marc Youcef
Marc Youcef on 5 May 2020
I am still having this issue on R2020a which is a long way from when that problem was first spot...

  0 Comments

Sign in to comment.


Antonio Javier Barragán Piña
Adding as first line of code this works for me (it is a comple clean of MATLAB environment):
clc, clear all, close all

  2 Comments

Riccardo Cambini
Riccardo Cambini on 31 May 2020
I had the same problem and this line solved it.
I used this code as the first line in the .mlx file, I ran it, and exported safely in .pdf.
I noticed also that you can cancel the line before exporting in .pdf. In other words, it seems that this line is needed just when you run the .mlx file, while you can leave it or not when exporting in .pdf.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by