Skip to content

Commit

Permalink
Open specific error in troubleshooting fixes #195 (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates authored and stanislas-m committed Apr 19, 2018
1 parent fc9a83b commit 74cbb23
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,3 +7,4 @@ bin/
.idea/
.vscode
gobuffalo.search/
.grifter/
15 changes: 13 additions & 2 deletions actions/helpers/help.go
Expand Up @@ -3,25 +3,36 @@ package helpers
import (
"html/template"

"github.com/gobuffalo/buffalo/render"
"github.com/gobuffalo/plush"
"github.com/pkg/errors"
)

func Faq(title string, help plush.HelperContext) (template.HTML, error) {
func Faq(title string, opts render.Data, help plush.HelperContext) (template.HTML, error) {
s, err := help.Block()
if err != nil {
return "", errors.WithStack(err)
}

name, ok := opts["name"].(string)
if !ok {
return "", errors.New("you must supply a name argument for `Faq`")
}

ctx := help.Context.New()
ctx.Set("title", title)
ctx.Set("body", s)
ctx.Set("name", name)
s, err = plush.Render(faqTmpl, ctx)
return template.HTML(s), err
}

const faqTmpl = `
<li>
<h6><%= markdown(title) %></h6>
<h6>
<%= markdown(title) %>
<a name="<%= name %>"></a>
</h6>
<div>
<%= markdown(body) %>
</div>
Expand Down
25 changes: 21 additions & 4 deletions assets/js/application.js
Expand Up @@ -21,20 +21,37 @@ var buildSideNav = () => {
}
});
if (items.length > 0) {
let ul = $('<ul class="summary">').append(items);
$('.main-content h1').after(ul);
let ul = $("<ul class=\"summary\">").append(items);
$(".main-content h1").after(ul);
sb.addClass("active");
}
};

var activateSideNav = () => {
let loc = window.location;
let path = loc.pathname === '/' ? '/docs/overview' : loc.pathname;
let path = loc.pathname === "/" ? "/docs/overview" : loc.pathname;
$(".sidebar li").removeClass("active");
let item = $(`.sidebar a[href="${path}"]`);
item.closest("li").addClass("active");
};


$(() => {
$(".faq h6").on("click", (e) => {
let a = $(e.currentTarget).find("a[name]");
let hash = a.attr("name");
window.location.hash = hash;
});
let hash = window.location.hash;
if (hash !== "") {
if (hash.charAt(0) === "#") {
hash = hash.slice(1);
}
$(`.faq h6 a[name=${hash}]`).click();
}
});


$(() => {
$("a[href]").each((_, a) => {
let $a = $(a);
Expand Down Expand Up @@ -88,7 +105,7 @@ $(() => {
});
});

// Handle language switch
//Handle language switch
$(() => {
$("#language").on("change", (e) => {
$(e.target).closest("form").submit();
Expand Down
28 changes: 14 additions & 14 deletions templates/docs/troubleshooting.html
Expand Up @@ -3,11 +3,11 @@
<div class="faq">
<input class="faq-search" type="text" placeholder="Type to search...">
<ul>
<%= faq("Can't find `buffalo` binary.") { %>
<%= faq("Can't find `buffalo` binary.", {name: "binary-not-found"}) { %>
If you can't find the `buffalo` binary after a successful installation, this is problably caused because `$GOPATH/bin`, or `%GOPATH\bin` (Windows), isn't in your `$PATH` variable. When a Go binary is installed it is placed in `$GOPATH/bin`. Adding this to your global `$PATH` will allow you to find **any** Go binary everywhere in your system. See [https://golang.org/doc/code.html#GOPATH](https://golang.org/doc/code.html#GOPATH) for more details.
<% } %>

<%= faq("`buffalo new` fails to generate a complete project.") { %>
<%= faq("`buffalo new` fails to generate a complete project.", {name: "failed-to-gen"}) { %>
This happens because the `buffalo new` command cannot find the templates it needs to generate a new application.

There are a couple of things that could cause this issue.
Expand All @@ -18,15 +18,15 @@
The original ticket for this issue can be found at [https://github.com/gobuffalo/buffalo/issues/629](https://github.com/gobuffalo/buffalo/issues/629).
<% } %>

<%= faq("`buffalo new` fails with NPM permissions issues.") { %>
<%= faq("`buffalo new` fails with NPM permissions issues.", {name: "npm-permissions"}) { %>
This is caused by incorrectly setup Node/NPM installation. See <a href="https://docs.npmjs.com/getting-started/fixing-npm-permissions" target="_blank">docs.npmjs.com/getting-started/fixing-npm-permissions</a> for information on how to fix this issue.
<% } %>

<%= faq("`buffalo dev` auto rebuild doesn't work with NFS.") { %>
<%= faq("`buffalo dev` auto rebuild doesn't work with NFS.", {name: "nfs-rebuild"}) { %>
This is caused by the `fsnotify` package not supporting NFS. See <a href="https://github.com/gobuffalo/buffalo/issues/620" target="_blank">github.com/gobuffalo/buffalo/issues/620</a> for more details and a workaround.
<% } %>

<%= faq("`buffalo new` fails with `import path does not begin with hostname`") { %>
<%= faq("`buffalo new` fails with `import path does not begin with hostname`", {name: "import-begins-hostname"}) { %>
This is caused by a mismatched `$GOPATH` and file system.

```
Expand All @@ -37,7 +37,7 @@
Those are not the same and cause problems with a lot of Go tools. Correct the `$GOPATH` to match the file system and retry.
<% } %>

<%= faq("`buffalo new` fails looking for `golang.org/x/tools/go/gcimporter`") { %>
<%= faq("`buffalo new` fails looking for `golang.org/x/tools/go/gcimporter`", {name: "gcimporter"}) { %>
This is caused by an outdated copy of the `github.com/motemen/gore` package. To fix simply update `gore`:

```text
Expand All @@ -47,7 +47,7 @@
For information see [https://github.com/gobuffalo/buffalo/issues/108](https://github.com/gobuffalo/buffalo/issues/108) and [https://github.com/motemen/gore/issues/63](https://github.com/motemen/gore/issues/63).
<% } %>

<%= faq("`buffalo dev` fails to start with `Unknown`") { %>
<%= faq("`buffalo dev` fails to start with `Unknown`", {name: "fails-unknown"}) { %>
When starting `$ buffalo dev`, and you encounter this error:

```text
Expand All @@ -59,7 +59,7 @@
If you are still having issues after attempting the steps above, please reach out to the community in the #buffalo channel on Gophers Slack.
<% } %>

<%= faq("`package context: unrecognized import path \"context\" (import path does not begin with hostname)`") { %>
<%= faq("`package context: unrecognized import path \"context\" (import path does not begin with hostname)`", {name: "unrecognized-context-import"}) { %>
When trying to install Buffalo `go get` returns this error:

```text
Expand All @@ -69,7 +69,7 @@
This is due to an outdated version of Go. Buffalo requires Go 1.7 or higher. Please check your installation of Go and ensure you running the latest version.
<% } %>

<%= faq("Error: `unexpected directory layout:` during `go get`") { %>
<%= faq("Error: `unexpected directory layout:` during `go get`", {name: "unexpected-dir-layout"}) { %>
Occasionally when running `go get` on Buffalo you will get the following error:

```text
Expand All @@ -85,21 +85,21 @@
The best way to solve this problem is to run `go get` again, and it seems to fix itself.
<% } %>

<%= faq("Error: in `application.js` from UglifyJs") { %>
<%= faq("Error: in `application.js` from UglifyJs", {name: "appjs-uglify"}) { %>
If you get this error when running `buffalo build` you need to update your `webpack.config.js` to work with [https://github.com/gobuffalo/buffalo/pull/350/files](https://github.com/gobuffalo/buffalo/pull/350/files).
<% } %>

<%= faq("Error: `Killed 9` when running `buffalo` on Mac OS X with Go 1.8.0") { %>
<%= faq("Error: `Killed 9` when running `buffalo` on Mac OS X with Go 1.8.0", {name: "mac-killed9"}) { %>
This is a known issue with Go, <a href="https://github.com/golang/go/issues/19734" target="_blank">github.com/golang/go/issues/19734</a>, not with Buffalo.

The best solution is to upgrade to Go 1.8.1, or greater, and rebuild your Go binaries.
<% } %>

<%= faq("Mac OS X: `Too many open files in system` error") { %>
<%= faq("Mac OS X: `Too many open files in system` error", {name: "mac-too-many-files"}) { %>
If you get this error when running `buffalo dev` that means you are "watching" too many files, either `.go` files or asset files. To correct this you can [change](http://blog.mact.me/2014/10/22/yosemite-upgrade-changes-open-file-limit) the maximum number of open files on your system.
<% } %>

<%= faq("`buffalo new` fails trying to run `goimports`") { %>
<%= faq("`buffalo new` fails trying to run `goimports`", {name: "new-goimports"}) { %>
The full error may appear something like the following, and seems to be the result of outdated go tools. To resolve run `rm -r $GOPATH/src/golang.org/`, then run `go get` again.
```bash
$ buffalo new myapp
Expand All @@ -111,7 +111,7 @@
```
<% }

<%= faq("`buffalo g goth` fails to generate `auth.go`") { %>
<%= faq("`buffalo g goth` fails to generate `auth.go`", {name: "goth-auth-fails"}) { %>
You might see errors similar to this when you build:
```bash
buffalo: 2018/01/19 20:58:47 === Error! ===
Expand Down

0 comments on commit 74cbb23

Please sign in to comment.