“调试位置是近似的,因为源不可用"在 R 4.0.0 + RStudio [英] "Debug location is approximate because the source is not available" in R 4.0.0 + RStudio

查看:79
本文介绍了“调试位置是近似的,因为源不可用"在 R 4.0.0 + RStudio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经更新到 R 4.0.0 和 RStudio 版本 1.2.5042.

I've updated to R 4.0.0 and RStudio version 1.2.5042.

我正在开发一个包,我经常使用以下工作流程:

I'm developing a package and I've regularly used the following workflow:

  1. 通过单击安装并重新启动"按钮(包括 --with-keep.source R CMD INSTALL 选项)从 RStudio 中构建包.
  2. 在我要调试的函数的 .R 文件中设置断点.
  3. 调用该函数并等待调试器准确地停止在我设置断点的位置.
  1. Build the package from within RStudio by clicking the "Install & Restart" button (including the --with-keep.source R CMD INSTALL option).
  2. Set a breakpoint in the .R file of the function I want to debug.
  3. Call the function and wait for the debugger to stop exactly where I set the breakpoint.

这曾经很好地工作.但是,现在我总是得到:

This used to work nicely. Now, however, I always get:

调试位置是大概的,因为源不可用

Debug location is approximate because the source is not available

这是 annyoing,因为我仍然可以调试,但我已经不在实际功能中了.

This is annyoing because I can still debug, but I'm not in the actual function anymore.

任何提示/想法为什么会这样?

Any hints/ideas why this is?

这似乎是 RStudio 和 R 4.0.0 的问题.这就是我这么认为的原因.我使用了另一台运行 Windows 10 的机器并执行了以下步骤(按此顺序;对于 Windows 用户应该可以重现).一开始我安装了 R 3.6.1 和 RStudio 1.2.5042(在撰写本文时,1.2.5042 是当前版本;也尝试使用 RStudio 的预览版 1.3.957).

It seems like this is an issue with RStudio and R 4.0.0. Here is why I think so. I used another machine running Windows 10 and did the following steps (in this order; should be reproducible for Windows users). At the outset I had R 3.6.1 and RStudio 1.2.5042 installed (at the time of writing 1.2.5042 was the current version; tried also with the preview version 1.3.957 of RStudio).

  1. 从 Github 克隆我正在开发的包:

  1. Clone the package I'm developing from Github:

git clone "https://github.com/M-E-Rademaker/cSEM"

  • 转到包根目录并打开cSEM.Rproj

    现在运行以下代码:

    model <- "
    # Structural model
    eta2 ~ eta1
    eta3 ~ eta1 + eta2
    
    # Measurement
    eta1 =~ y11 + y12 + y13
    eta2 =~ y21 + y22 + y23
    eta3 =~ y31 + y32 + y33
    "
    
    res <- csem(threecommonfactors, model)
    

    调试器应该启动并带你到第 321 行.你应该能够改变代码并且你应该得到debug-location-is-approximate-because-the-source-is-not-availabe" 警告如果您使用的是低于 4.0.0 的 R 版本.

    The debugger should start and take you right to line 321. You should be able to alter code and you should NOT get the "debug-location-is-approximate-because-the-source-is-not-availabe" warning IF you are on an R version below 4.0.0.

    这是为什么?欢迎任何想法/提示/建议!!

    Why is that? Any ideas/hints/suggestions are welcome!!

    我尝试过的其他事情:

    • 从 win-library 中删除软件包并重新安装
    • 使用 devtools::install_github()
    • 从 GitHub 重新安装包
    • 检查包根目录
    • 更新所有依赖包
    • 在不同的机器上重复这个过程
    • 我开发了另一个包,您可以在此处从 GitHub 克隆:https://github.com/ME-Rademaker/cSEM.DGP.您可以使用这个包运行相同的过程,但是,在这里我在使用 4.0.0 时没有收到警告......我认为这非常奇怪.
    • Deleting the package from win-library and reinstalling
    • Reinstalling the package from GitHub using devtools::install_github()
    • Checked package root
    • Updated all dependency packages
    • Repeated the procedure on different machines
    • I develop another package which you can clone from GitHub here: https://github.com/M-E-Rademaker/cSEM.DGP. You can run the same procedure with this package, however, here I dont get the warning when using 4.0.0...which is extremly odd I think.

    推荐答案

    我使用你的包进行了调查,发现你在这里看到的是 RStudio/R 界面中相当深的一个错误,由 R 的一些细微变化引起在 R 4.0 中围绕源引用制作.

    I investigated this using your package and discovered that what you're seeing here is a bug fairly deep in the RStudio / R interface, caused by some subtle changes R made in R 4.0 around source references.

    只要函数代码中有反斜杠 (\),就会出现问题.发生这种情况时,R 正在对其进行转义,这导致 RStudio 认为您正在查看的函数副本与文件中的副本不同,这反过来又导致它在代码浏览器中向您显示副本而不是打开文件本身.

    The problem happens whenever there's a backslash (\) in a function's code. When that happens, R is escaping it, which causes RStudio to think that the copy of the function you're looking at is different than the one in the file, which in turn causes it to show you a copy in a code browser instead of opening the file itself.

    由于您的 csem() 函数包含反斜杠,因此会触发该问题.我已经在我们的问题跟踪器上写下了这个:

    Since your csem() function contains a backslash it triggers the issue. I've written this up on our issue tracker here:

    https://github.com/rstudio/rstudio/issues/6854

    这篇关于“调试位置是近似的,因为源不可用"在 R 4.0.0 + RStudio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆