R Studio pauses running the code every time there is an error - rstudio

RStudio pauses every time there is an error, even when the error doesn't affect the output. Here is what I have tried to fix so far:
Change the settings:
Debug -> On Error > Message only
Tools -> Global Options and uncheck “Use debug error handler only when my code contains errors”.
Reinstall RStudio and R
Update: I reinstalled prior version of R studio and it solved the problem

Have you tried doing Ctrl+A to highlight the document and then Ctrl+Enter to run? It should execute all lines of code regardless of errors.

Related

How to get VS Code to scroll to source line when breakpoint hit

When VS Code encounters a breakpoint that pauses the program, I expect the source file to be opened and the exact line of execution scrolled into view. This used to work, but it has mysteriously stopped. I have searched for a setting using words like "breakpoint", "debug", and "scroll" but have had no luck.
This seems to be happening only for my golang project, as the expected breakpoint behavior happens in a python project. I am running VS Code Go Extension v0.37.1, VS Code version 1.75.1.

Spyder debugger freezes on second restart of code

My task is to repeatedly rerun a code from beginning. As I do not want to run the code to the end I set a breakpoint() command. However, Spyder freezes when the code is the second time called from debug mode. For demonstration a simple program is sufficient:
print('Hello World!')
breakpoint()
After launching Spyder I start the small program by F5. Everything works as expected and I jumped into the debug mode. Now I press again F5 and the code restarts correctly from the debug mode. After again pressing F5 the code is not restarted and instead the IDE freezes. It is not possible by any means to rerun the code again from debug mode. Interrupting the kernel by pressing the red button (see screenshot below) does not help. Trying to leave the debug mode by !q does not leave the debug mode. The only possibility to rerun the code is quite cumbersome, i.e. I have to restart the kernel (Ctrl+.) that takes a while. How to debug code under these circumstances?
Is this a bug of the IDE or expected behavior? How can I restart the code by a simple key press as often as possible from debug mode?
This is a screenshot of the Spyder console with comments in red added.
I use a recent version a WinPython with latest Spyder 5.4.0, Python 3.10.4 64-bit, Qt 5.15.2, PyQt5 5.15.6, Windows 10Pro Version 21H2. The problem also appears with Spyder 5.3.3 A similar problem (or maybe the same) appears with a different Python version.
After many trials, I noticed that there is something strange with IPython console. I noticed that when it hangs after running a code, if I delete all user variables, it worked fine.
Then I tryed to delete all variables before execution, and it work fine.
Therefore I discovered that a solution that worked for me is to go to preferences -> Run -> and untick the option 'Remove all variables before execution'
It is quite annoying because I have to do it manually every time before running, but in this way the spyder does not appear to hang anymore! I hope that the Spyder developers will solve it soon.
-
I automatically solved by typing at the beginning of any script these lines, inspired from the question Code to clear console and variables in Spyder :
try:
from IPython import get_ipython
get_ipython().magic('clear')
get_ipython().magic('reset -f')
import matplotlib.pyplot as plt
plt.close('all')
except:
pass
similar to Matlab in which you normally start your code with
clc
close all
clear all

How to run/test code in visual studio code?

How can I run/text code in visual studio code? What I mean if, for example, I have the following code:
i = 0
while i < 5:
print("test")
i += 1
then I would like to get the output:
test
test
test
test
test
I used jupyter notebook before and this was possible but I can't do this in vscode and they're forcing me to use vscode.
Press F5. You can set a breakpoint by clicking to the left of you line number. See VS Code Debugging for more information. You'll need to install the ms-python extension to get python support (see the above link). Naturally, you can simply invoke your compiler in the terminal as well (Control+` to bring up terminal).

Start without debugging doesn't run - blank cmd - and after an error on any attempt to run

Visual Studio 2015 Community
So I am new to Visual Studio completely. It works perfectly on my desktop, but I am having this problem on my laptop. Here is the gist of it -
I just write something to print the numbers 0 - 10. If I hit F5, it builds and flashes on the screen real quick, as expected. Next, I hit Ctrl F5 - cmd opens and is blank, just the flashing line. It does not run. I close the cmd window (have tried just hitting return/any key on the blank window). After closing, if I try to run it again, either F5 or Ctrl F5, I get the error:
Could not copy "obj\Debug\ConsoleApplication2.exe" to "bin\Debug\ConsoleApplication2.exe". Exceeded retry count of 10. Failed.
I have looked around for a solution and even though both of these separate issues are talked about, cannot find any solution to either of them.
If I go to task manager, I have several ConsoleApplication2.exe*32 processes - I can kill all of them but two. No matter what I do I cannot terminate them, and cannot delete the src/bin folders as I saw someone suggest.
Further, even if I figure out how to kill these processes so I can run again, it still doesn't help me with why Ctrl F5 just doesn't run.
Can anyone help or point me in a direction to a possible cause for this? I tried repairing, uninstalling and reinstalling, and several other suggestions and nothing seems to work. I am going crazy trying to get this to work.
I think it's your anti-virus .. especially if you're using Avast. It causes the same issue for me.
To solve it add exclusion to your anti-virus:

Visual Studio 2010 suddenly stops displaying Debug output

So there I am, working on a Silverlight app, and between one build & run and the next, my debug output goes away. Where before I had dozens of lines of Debug.Writeline text, I now have only the module load and thread messages.
Yes, I'm in debug mode (vs. release mode).
Yes, my Output window says "Show output from: Debug".
Yes, when I right-click on the output window, every option is checked.
No, my Tools > options > debugging > general > "Redirect all output text to the immediate window" is not checked.
All I can figure (and it's a wild guess) is that for some reason, the VS debugger isn't attaching to the Silverlight app like it should.
What's weird is this has been happening for the last couple of days, out of the blue. And just as suddenly, all my debug messages start showing up again.
This is VERY frustrating.
EDIT: Of course, after returning to the project after the weekend, all Debug messages are back. No idea what was causing the issue, so I'm sure it will happen again.
Now the question is: should I leave this question open in case the problem arises again in the near future? What happens to an unawarded bounty?
I found the same problem and just by setting options → debugging → output window → Thread Exit Messages to true the output windows was begin to send the right messages !?
I had exactly the same issue. Out of the blue, debug.print stopped working. In my case, it used to go to the Immediate Window. Nothing there. Nothing in the Output window. I followed several suggestions to no avail until I found this one at http://www.experts-exchange.com/questions/26894732/Debug-Print-and-Debug-Write-no-longer-work-in-Visual-Studio-2010.html
There is a context menu in the Output/Debug pane. The "Program Output"
menu item was accidentally cleared.
Checked the item and it started working again (even though my output was the immediate window). What a relief...
Ensure that the DEBUG conditional compilation symbol is defined. The Debug class suggests that you "add the /d:DEBUG option to the compiler command line when you compile your code using a command line, or add #define DEBUG to the top of your file".
Did you create or modify an Application config? If yes: the initial created configuration by VS does contains the necessary wiring configurations to enable the debugging at all. Not sure what and if there are counterparts in Silverlight, but in WPF environments simply replacing the app.config will have the same effect as you expierience.
Check the Immediate Window. Check the options. There is a general setting that says "send Debug output to Immediate Window"

Resources