{"id":17232,"date":"2022-11-08T09:30:33","date_gmt":"2022-11-08T14:30:33","guid":{"rendered":"https:\/\/qxf2.com\/blog\/?p=17232"},"modified":"2022-11-08T09:30:33","modified_gmt":"2022-11-08T14:30:33","slug":"unresponsive-function-while-creating-new-project-in-rust","status":"publish","type":"post","link":"https:\/\/qxf2.com\/blog\/unresponsive-function-while-creating-new-project-in-rust\/","title":{"rendered":"Unresponsive function while creating new project in Rust"},"content":{"rendered":"<p><\/a>While working on a rust-based hackathon project at <a href=\"https:\/\/qxf2.com\/?utm_source=unresponsive_func&#038;utm_medium=click&#038;utm_campaign=From%20blog\" rel=\"noopener\" target=\"_blank\">Qxf2<\/a>, I encountered an unresponsive function when creating new project in Rust.<\/p>\n<p>Being a newbie in rust, I was unable to figure out the cause. I tried looking up the internet but could not find any suitable solutions. Hence, I thought of documenting the resolution to this issue so that anyone hitting with same issue wouldn&#8217;t have to waste hours finding the cause.<\/p>\n<hr>\n<h4>Problem<\/h4>\n<p>To begin with, I had to build a Rust function for AWS lambda. To do this, I first tried creating a project which would give me the default template with the following command.<\/p>\n<p><strong>cargo lambda new rust_lambda<\/strong><\/p>\n<p>When you execute the command, you are shown the following in the terminal.<\/p>\n<p><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2022\/10\/cargo-6.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2022\/10\/cargo-6-1024x523.png\" alt=\"\" width=\"900\" height=\"460\" class=\"alignnone size-large wp-image-17263\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2022\/10\/cargo-6-1024x523.png 1024w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2022\/10\/cargo-6-300x153.png 300w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2022\/10\/cargo-6-768x392.png 768w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2022\/10\/cargo-6-1536x785.png 1536w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2022\/10\/cargo-6.png 1893w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/a><\/p>\n<pre lang=\"yml\">\r\n? Is this function an HTTP function? (y\/N)\r\n[type `yes` if the Lambda function is triggered by an API Gateway, Amazon Load Balancer(ALB), or a Lambda URL]\r\n<\/pre>\n<p>In my case, the lambda function was not triggered with any of the above, so I chose &#8216;No&#8217; and hit enter and got none in the response i.e. the cursor just stayed at the same place without giving me a success or any error message.<\/p>\n<p>The difficulty was not getting any error message and so, I was not sure why the command was not getting executed.<\/p>\n<hr>\n<h4>Root cause<\/h4>\n<p>I had to do trial and error before finding the root cause of the issue. It was the rust version. Sound simple, right? \ud83d\ude42 but this took a while. I was using rust 1.61.0 and updating it to the latest version helped resolve the issue. I would be happier if it were shown on the terminal but that gave me a way to dig deeper.<\/p>\n<hr>\n<h4>Solution<\/h4>\n<p>The next step was to <a href=\"https:\/\/rust-lang.github.io\/rustup\/basics.html\" rel=\"noopener\" target=\"_blank\">update<\/a> the rustup which was the installer in my case with the following command:<\/p>\n<p><strong>rustup update stable<\/strong><\/p>\n<p><strong>Before Update<\/strong><\/p>\n<p>$ rustc &#8211;version<br \/>\nrustc 1.61.0 (fe5b13d68 2022-05-18)<\/p>\n<p>$ cargo &#8211;version<br \/>\ncargo 1.61.0 (a028ae42f 2022-04-29)<\/p>\n<p><strong>After update<\/strong><\/p>\n<p>$ rustc &#8211;version<br \/>\nrustc 1.64.0 (a55dd71d5 2022-09-19)<\/p>\n<p>$ cargo &#8211;version<br \/>\ncargo 1.64.0 (387270bc7 2022-09-16)<\/p>\n<p>Once, the rust is updated to the newer version, you can again run the cargo lambda new command.<\/p>\n<hr>\n<h4>Conclusion<\/h4>\n<p>I have come across a few scenarios in Rust where the issues arise due to version incompatibility. Hence, It is better to have the updated version while working with rust projects.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While working on a rust-based hackathon project at Qxf2, I encountered an unresponsive function when creating new project in Rust. Being a newbie in rust, I was unable to figure out the cause. I tried looking up the internet but could not find any suitable solutions. Hence, I thought of documenting the resolution to this issue so that anyone hitting [&hellip;]<\/p>\n","protected":false},"author":38,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[306],"tags":[321,308],"class_list":["post-17232","post","type-post","status-publish","format-standard","hentry","category-rust","tag-aws-lambda","tag-rust"],"_links":{"self":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/17232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/users\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/comments?post=17232"}],"version-history":[{"count":38,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/17232\/revisions"}],"predecessor-version":[{"id":17288,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/17232\/revisions\/17288"}],"wp:attachment":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/media?parent=17232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/categories?post=17232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/tags?post=17232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}