btcpayserver: System.Exception: Unable to load bundles (HTTP 500 on initial load web UI)

After successful installation and startup of BTCPay server, an error occurs the first time I try to access the web UI on port 23001. HTTP 500 is returned to the web client and a System Exception occurs in the btcpay logs (logs at the end of this issue)

  • Version of BTCPay Server: v1.0.3.88 (also failing for several other 1.0.3.xx versions tested)
  • Deployment method: Manual Build
  • Other relevant environment details: Ubuntu 16.04

To Reproduce

  • Build and run BTCPay from systemctl startup script
  • BTCPay uccessfully connects to NBXplorer and sees new blocks
  • BTCPay starts HTTP server on 23001
  • On initial HTTP get of localhost:23001, HTTP500 is returned.
  • Logs show system exception in LoadBundles()

Additional details:

  • BTCPay server is running as a non-administrative user.
  • daemon user and group have full access to the btcpayserver build and launch directory
  • It worked before “bundles”
  • Crash happens even when bundlejscss is set to false
  • Additional logging added to the code shows that bundlejscss is correctly read as “false” in the daemon execution.
  • Daemon user has full file access to bundleconfig.json
  • Even when setting 777 permisions on bundleconfig.json, it still crashes
 System.Exception: Unable to load bundles.
    at Meziantou.AspNetCore.BundleTagHelpers.BundleProvider.LoadBundles()
    at Meziantou.AspNetCore.BundleTagHelpers.BundleProvider.GetBundle(String name)
    at Meziantou.AspNetCore.BundleTagHelpers.BundleTagHelper.Process(TagHelperContext context, TagHelperOutput output)
    at Microsoft.AspNetCore.Razor.TagHelpers.TagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output)
    at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.RunAsync(TagHelperExecutionContext executionContext)
    at AspNetCore.Views_Shared__Layout.<ExecuteAsync>b__44_0() in /usr/local/src/BTCPayServer/btcpayserver/BTCPayServer/Views/Shared/_Layout.cshtml:line 27
    at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync()
    at AspNetCore.Views_Shared__Layout.ExecuteAsync()
    at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
    at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
    at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderLayoutAsync(ViewContext context, ViewBufferTextWriter bodyWriter)
    at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
    at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
    at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, String contentType, Nullable`1 statusCode)
    at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
    at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultAsync(IActionResult result)
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResultFilterAsync[TFilter,TFilterAsync]()
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultFilters()
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
    at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
    at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
    at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
    at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
    at BTCPayServer.Hosting.BTCPayMiddleware.Invoke(HttpContext httpContext) in /usr/local/src/BTCPayServer/btcpayserver/BTCPayServer/Hosting/BTCpayMiddleware.cs:line 55
    at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.Invoke(HttpContext context)
    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 23 (19 by maintainers)

Commits related to this issue

Most upvoted comments

I managed to isolate the problem to the systemd start script. I copied from the run.sh contents and this command line worked:

ExecStart=/usr/bin/dotnet run --no-launch-profile --no-build -c Release -p "BTCPayServer/BTCPayServer.csproj" --conf /data/btcpayserver/btcpayserver.conf --datadir /data/btcpayserver/

The problem was all in how I launched BTCPay from systemd. I had copied the systemd from one of the tutorials, and it didn’t work.

Yep, I confirm it works for me now. 😃 @aantonop if you use bundlejscss to true (as it should be normally), you won’t have permission issue as I read the bundle.config directly from the resources of the assembly.

@aantonop I tried brand new VM, manual install and it just worked.

Install Bitcoin Core 0.17.0

BITCOIN_VERSION="0.17.0"
BITCOIN_URL="https://bitcoincore.org/bin/bitcoin-core-0.17.0/bitcoin-0.17.0-x86_64-linux-gnu.tar.gz"
BITCOIN_SHA256="9d6b472dc2aceedb1a974b93a3003a81b7e0265963bd2aa0acdcb17598215a4f"

# install bitcoin binaries
cd /tmp
wget -O bitcoin.tar.gz "$BITCOIN_URL"
echo "$BITCOIN_SHA256 bitcoin.tar.gz" | sha256sum -c - && \
mkdir bin && \
sudo tar -xzvf bitcoin.tar.gz -C /usr/local/bin --strip-components=2 "bitcoin-$BITCOIN_VERSION/bin/bitcoin-cli" "bitcoin-$BITCOIN_VERSION/bin/bitcoind"
rm bitcoin.tar.gz

Install .NET Core SDK 2.1: On my ubuntu 16.04: (See those instructions for different OS).

wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install -y dotnet-sdk-2.1

Install NBXplorer

cd ~
git clone https://github.com/dgarage/NBXplorer
cd NBXplorer
git checkout latest
./build.sh

Install BTCPayServer

cd ~
git clone https://github.com/btcpayserver/btcpayserver
cd btcpayserver
git checkout latest
./build.sh

Run bitcoind:

bitcoind

Run nbxplorer:

cd ~/NBXplorer
./run.sh

Run BTCPayServer:

cd ~/btcpayserver
./run.sh --port 8080 --bind 0.0.0.0

Now you can browse your server on port 8080.

Can you repro this?

OK, missing reference to BundlerMinifier.Core was what was causing the problem in some cases I guess:

https://github.com/btcpayserver/btcpayserver/commit/0578a692db119a4297ff168009fb46a77664382b#diff-6a9de8749b532027dc48bb5be3e83b03R39

If you pull and build with this latest commit @aantonop - it should work. Plus with fix @NicolasDorier has provided, we are now good with upgrading to .NET Core 2.2 when it’s time. ❤️